<?php

namespace App\Filament\Resources\FacilityResource\Pages;

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

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

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

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

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