<?php

declare(strict_types=1);

namespace App\Filament\Resources\Attachments\Pages;

use App\Domain\Media\AttachmentStorageService;
use App\Filament\Resources\Attachments\AttachmentResource;
use App\Models\Attachment;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;

class EditAttachment extends EditRecord
{
    protected static string $resource = AttachmentResource::class;

    protected function getHeaderActions(): array
    {
        return [
            DeleteAction::make()
                ->before(function (Attachment $record, AttachmentStorageService $storage): void {
                    $storage->deleteFromDisk($record);
                }),
        ];
    }
}
