<?php

namespace App\Domains\Invoice\Controllers;

use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceCommand;
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceRequest;
use App\Enumerations\CostUnitType;
use App\Enumerations\InvoiceType;
use App\Models\CostUnit;
use App\Providers\FlashMessageProvider;
use App\Providers\InertiaProvider;
use App\Providers\UploadFileProvider;
use App\Scopes\CommonController;
use App\ValueObjects\Amount;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class NewInvoiceController extends CommonController {
    public function __invoke() {
        $userData = $this->users->getCurrentUserDetails();

        $runningJobs = $this->costUnits->getCostUnitsForNewInvoice(CostUnitType::COST_UNIT_TYPE_RUNNING_JOB);
        $currentEvents = $this->costUnits->getCostUnitsForNewInvoice(CostUnitType::COST_UNIT_TYPE_EVENT);


        $inertiaProvider = new InertiaProvider('Invoice/NewInvoice', [
            'userName' => $userData['userName'],
            'userEmail' => $userData['userEmail'],
            'userTelephone' => $userData['userTelephone'],
            'userAccountOwner' => $userData['userAccountOwner'],
            'userAccountIban' => $userData['userAccountIban'],
            'runningJobs' => $runningJobs,
            'currentEvents' => $currentEvents,
        ]);
        return $inertiaProvider->render();
    }
}
