<?php

namespace App\Filament\Resources\Fixtures\Pages;

use App\Enums\MatchStatus;
use App\Filament\Resources\Fixtures\FixtureResource;
use Carbon\Carbon;
use Filament\Resources\Pages\CreateRecord;

class CreateFixture extends CreateRecord
{
    protected static string $resource = FixtureResource::class;

    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $startsAt = Carbon::parse($data['starts_at']);

        $data['picks_lock_at'] = $startsAt->copy()->subMinutes(15);
        $data['status'] = MatchStatus::Scheduled->value;
        $data['home_score'] = null;
        $data['away_score'] = null;
        $data['result'] = null;
        $data['result_declared_at'] = null;

        return $data;
    }
}
