<?php

declare(strict_types=1);

namespace App\Filament\Resources\WithdrawalRequests;

use App\Filament\Resources\WithdrawalRequests\Pages\ListWithdrawalRequests;
use App\Models\WithdrawalRequest;
use App\Filament\Support\NavigationBadge;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use UnitEnum;

class WithdrawalRequestResource extends Resource
{
    protected static ?string $model = WithdrawalRequest::class;

    protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-banknotes';

    protected static ?string $navigationLabel = 'درخواست‌های برداشت';

    protected static ?string $modelLabel = 'درخواست برداشت';

    protected static ?string $pluralModelLabel = 'درخواست‌های برداشت';

    protected static string|null|UnitEnum $navigationGroup = 'مالی';

    public static function table(Table $table): Table
    {
        return \App\Filament\Resources\WithdrawalRequests\Tables\WithdrawalRequestsTable::configure($table);
    }

    public static function getPages(): array
    {
        return [
            'index' => ListWithdrawalRequests::route('/'),
        ];
    }

    public static function getNavigationBadge(): ?string
    {
        return NavigationBadge::fromQuery(
            fn () => static::getModel()::query()->where('status', WithdrawalRequest::STATUS_PENDING)
        );
    }

    public static function getNavigationBadgeColor(): ?string
    {
        return NavigationBadge::colorFromQuery(
            fn () => static::getModel()::query()->where('status', WithdrawalRequest::STATUS_PENDING)
        );
    }
}
