<?php

namespace App\Filament\Pages\AdminVerification\Actions;

use App\Enums\DecisionAdmin;
use App\Filament\Pages\AdminVerification\Concerns\CanProcessVerificationReview;
use App\Filament\Support\CheerfulNotification;
use Filament\Actions\Action;

class ApproveAction extends Action
{
    use CanProcessVerificationReview;

    public static function getDefaultName(): ?string
    {
        return 'approve';
    }

    protected function setUp(): void
    {
        parent::setUp();

        $this->label('Setujui')
            ->authorize(fn (): bool => auth()->user()?->can('Approve:AdminVerification'))
            ->color('success')
            ->icon('heroicon-o-check')
            ->size('sm')
            ->link()
            ->requiresConfirmation()
            ->modalHeading(fn () => CheerfulNotification::getByKey('actions.approve.title'))
            ->modalDescription(fn () => CheerfulNotification::getByKey('actions.approve.description'))
            ->modalSubmitActionLabel('Ya, Setujui')
            ->action(function (array $arguments): void {
                $this->processReview($arguments['id'], DecisionAdmin::APPROVED, null);
            });
    }
}
