<?php

declare(strict_types=1);

namespace App\Support;

use App\Business\Settlement\SettlementRuleService;
use Filament\Actions\Action;

final class DberpFilamentSettlementVoidActionConfigurator
{
    public static function settlementVoidAllowed(): bool
    {
        return app(SettlementRuleService::class)->allowsSettlementVoid();
    }

    public static function configureEffectiveSettlementVoidAction(Action $action): Action
    {
        return $action
            ->disabled(fn (): bool => ! self::settlementVoidAllowed())
            ->tooltip(fn (): ?string => self::settlementVoidAllowed()
                ? null
                : (string) __('dberp.hints.settlement_void_policy_disabled_reason'));
    }
}
