<?php

namespace App\Http\Resources;

use App\LeadExports\LeadExportFieldType;
use App\Models\LeadExport;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class LeadExportTemplateResource extends JsonResource
{
    public static $wrap = '';

    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    #[\Override]
    public function toArray(Request $request): array
    {
        $data = parent::toArray($request);

        return array_merge($data, [
            'data_options' => [
                'modes' => LeadExport::modeOptions(),
                'field_types' => collect(LeadExportFieldType::TYPES)
                    ->map(fn ($type) => ['id' => $type, 'name' => $type])
                    ->values(),
            ],
        ]);
    }
}
