<?php

declare(strict_types=1);

namespace App\Filament\Actions\Storage\Base;

use App\Actions\Storage\Base\PruneAction as BasePruneAction;
use App\Filament\Actions\Storage\StorageAction;
use App\Filament\Components\Fields\TextInput;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Illuminate\Database\Eloquent\Model;

abstract class PruneAction extends StorageAction
{
    protected function setUp(): void
    {
        parent::setUp();

        $this->icon(Heroicon::OutlinedTrash);
    }

    public function getSchema(Schema $schema): Schema
    {
        return $schema
            ->components([
                TextInput::make('hours')
                    ->label(__('filament.actions.storage.prune.fields.hours.name'))
                    ->helperText(__('filament.actions.storage.prune.fields.hours.help'))
                    ->numeric(),
            ]);
    }

    /**
     * Get the underlying storage action.
     *
     * @param  array<string, mixed>  $data
     */
    abstract protected function storageAction(?Model $record, array $data): BasePruneAction;
}
