<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpRegions\Pages;

use App\Business\MasterData\DberpManualRegionCreationService;
use App\Filament\Resources\DberpRegions\DberpRegionResource;
use App\Filament\Resources\Pages\CreateRecord;
use Filament\Schemas\Schema;
use Illuminate\Contracts\Support\Htmlable;

class CreateDberpRegion extends CreateRecord
{
    protected static string $resource = DberpRegionResource::class;

    public function getTitle(): string|Htmlable
    {
        return __('dberp.actions.add_region');
    }

    public function form(Schema $schema): Schema
    {
        return DberpRegionResource::manualCreateForm($schema);
    }

    /**
     * @param  array<string, mixed>  $data
     * @return array<string, mixed>
     */
    protected function mutateFormDataBeforeCreate(array $data): array
    {
        return app(DberpManualRegionCreationService::class)->buildCreatePayload($data);
    }
}
