<?php

declare(strict_types=1);

namespace App\Filament\Resources\ProjectCompletions;

use App\Filament\Resources\ProjectCompletions\Pages\ListProjectCompletions;
use App\Filament\Resources\ProjectCompletions\Tables\ProjectCompletionsTable;
use App\Filament\Support\NavigationBadge;
use App\Models\ProjectCompletion;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use UnitEnum;

class ProjectCompletionResource extends Resource
{
    protected static ?string $model = ProjectCompletion::class;

    protected static string|BackedEnum|null $navigationIcon = \Filament\Support\Icons\Heroicon::OutlinedCheckBadge;

    protected static ?string $navigationLabel = 'تکمیل پروژه‌ها';

    protected static ?string $modelLabel = 'تکمیل پروژه';

    protected static ?string $pluralModelLabel = 'تکمیل پروژه‌ها';

    protected static string|null|UnitEnum $navigationGroup = 'پروژه‌ها و سفارشات';

    protected static ?int $navigationSort = 3;

    public static function table(Table $table): Table
    {
        return ProjectCompletionsTable::configure($table);
    }

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

    public static function getNavigationBadge(): ?string
    {
        return NavigationBadge::fromQuery(
            fn () => static::getModel()::query()->whereNull('finalized_at')
        );
    }

    public static function getNavigationBadgeColor(): ?string
    {
        return NavigationBadge::colorFromQuery(
            fn () => static::getModel()::query()->whereNull('finalized_at')
        );
    }
}
