<?php

namespace App\Livewire\JobCards;

use Livewire\Component;
use App\Models\JobCard;
use App\Services\WorkflowService;

class WorkflowStatus extends Component
{
    public JobCard $jobCard;
    public $workflowData;

    public function mount(JobCard $jobCard)
    {
        $this->jobCard = $jobCard->load([
            'customer',
            'vehicle',
            'serviceAdvisor',
            'incomingInspection.inspector',
            'outgoingInspection.inspector',
            'diagnosis.serviceCoordinator',
            'estimates.preparedBy',
            'workOrders.assignedTechnician',
            'workOrders.serviceCoordinator',
            'timesheets.technician'
        ]);

        $workflowService = app(WorkflowService::class);
        $this->workflowData = $workflowService->getWorkflowStatus($this->jobCard);
    }

    public function render()
    {
        return view('livewire.job-cards.workflow');
    }
}
