<?php

namespace App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\Pages;

use App\Filament\Clusters\WeeklyOps\Resources\TaskCollections\TaskCollectionResource;
use App\Filament\Resources\Pages\AuditedEditRecord;
use App\Services\Audit\SuperAdminAuditLogger;
use Filament\Actions;

class EditTaskCollection extends AuditedEditRecord
{
    protected static string $resource = TaskCollectionResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make()
                ->after(fn ($record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
                    'deleted',
                    $record,
                    source: static::class
                )),
        ];
    }

    protected function mutateFormDataBeforeSave(array $data): array
    {
        return TaskCollectionResource::normalizeData($data, $this->record);
    }
}
