<?php

namespace App\Filament\Resources\Streaks;

use App\Filament\Resources\Streaks\Pages\ListStreaks;
use App\Filament\Resources\Streaks\Schemas\StreakInfolist;
use App\Filament\Resources\Streaks\Tables\StreaksTable;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Functional\Streaks\Models\Streak;
use Illuminate\Database\Eloquent\Model;
use UnitEnum;

/**
 * Streaks calculés par StreakService (1 par user) — consultation + suppression uniquement,
 * jamais de création/édition manuelle depuis le back-office.
 */
class StreakResource extends Resource
{
    protected static ?string $model = Streak::class;

    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedFire;

    protected static string|UnitEnum|null $navigationGroup = 'Gamification';

    protected static ?int $navigationSort = 1;

    protected static ?string $modelLabel = 'streak';

    protected static ?string $pluralModelLabel = 'streaks';

    public static function infolist(Schema $schema): Schema
    {
        return StreakInfolist::configure($schema);
    }

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

    public static function canCreate(): bool
    {
        return false;
    }

    public static function canEdit(Model $record): bool
    {
        return false;
    }

    /**
     * @return array<int, string>
     */
    public static function getGloballySearchableAttributes(): array
    {
        return ['user.name'];
    }

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