<?php

namespace App\Modules\SalesChannels;

use App\Contracts\AddsDealershipFields;
use App\Contracts\SalesChannel;
use App\Facades\Settings;
use App\Jobs\VehiclesInVideoExportJob;
use App\Traits\ChecksForExportMap;
use Illuminate\Foundation\Bus\DispatchesJobs;

class VehiclesInVideo implements SalesChannel, AddsDealershipFields
{
    use DispatchesJobs;
    use ChecksForExportMap;

    public function enabled(): bool
    {
        return (bool)Settings::get('sales-channels-vehicles-in-video-enabled');
    }

    public function name(): string
    {
        return __('sales_channels.vehicles_in_video');
    }

    public function runScheduledExport(): void
    {
        if ($this->enabled() && !$this->hasActiveExportMap()) {
            $this->dispatch(new VehiclesInVideoExportJob());
        }
    }

    public function dealershipAdditionalDataFields(): array
    {
        return [
            'vehicles-in-video-garage-ref' => [
                'type' => 'text',
                'label' => 'Garage Ref Number on Vehicles In Video',
            ],
        ];
    }
}
