#include "campseller.h"

#include "campwizard.h"
#include "campservice.h"
#include "data/camp-data.h"
#include "campshopitem.h"

CampSeller::CampSeller(QObject *parent)
    :ISeller(parent)
{  
}

void CampSeller::prepareItem()
{
    CampWizard *wizard = new CampWizard();
    wizard->setAttribute(Qt::WA_DeleteOnClose);

    CampService srv;
    CampDataPtr data = srv.create();
    wizard->setData(data);
    wizard->setNewRecord(true);
    wizard->show();

    connect(wizard, &QDialog::accepted, [this, data](){
        CampShopItemPtr item(new CampShopItem);
        item->setUnitPrice(data->totalPrice());
        item->setId(data->id());
        emit itemPrepared(item, 1);
    });
}
