<?php

declare(strict_types=1);

namespace App\Filament\Resources\WalletTransactions;

use App\Filament\Resources\WalletTransactions\Pages\ListWalletTransactions;
use App\Models\WalletTransaction;
use App\Filament\Support\NavigationBadge;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use UnitEnum;

class WalletTransactionResource extends Resource
{
    protected static ?string $model = WalletTransaction::class;

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

    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\WalletTransactions\Tables\WalletTransactionsTable::configure($table);
    }

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

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

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