<?php

namespace App\Filament\Resources\SemesterResource\Pages;

use App\Filament\Resources\SemesterResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Gate;
class EditSemester extends EditRecord
{
    protected static string $resource = SemesterResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make()
                ->before(function () {
                    // Add any pre-delete logic here
                })
                ->visible(fn () => Gate::allows('delete semester')),
            Actions\ForceDeleteAction::make()
                ->visible(fn () => Gate::allows('force delete semester')),
            Actions\RestoreAction::make()
                ->visible(fn () => Gate::allows('restore semester')),
        ];
    }

    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }

    protected function getSavedNotification(): ?Notification
    {
        return Notification::make()
            ->success()
            ->title('Semester updated')
            ->body('The semester has been updated successfully.');
    }

    protected function mutateFormDataBeforeSave(array $data): array
    {
        // Add any data transformation logic here
        return $data;
    }
}