<?php

namespace App\Filament\Resources\Exercises;

use App\Filament\Resources\Exercises\Pages\ListExercises;
use App\Filament\Resources\Exercises\Schemas\ExerciseInfolist;
use App\Filament\Resources\Exercises\Tables\ExercisesTable;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Functional\Exercises\Models\Exercise;
use UnitEnum;

/**
 * Catalogue d'exercices — consultation en lecture seule (1324 lignes).
 * Filtrable par body_part / equipment / target, recherche sur le nom.
 */
class ExerciseResource extends Resource
{
    protected static ?string $model = Exercise::class;

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

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

    protected static ?int $navigationSort = 1;

    protected static ?string $modelLabel = 'exercice';

    protected static ?string $pluralModelLabel = 'exercices';

    protected static ?string $recordTitleAttribute = 'name';

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

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

    // Catalogue en lecture seule : pas de création / édition / suppression.
    public static function canCreate(): bool
    {
        return false;
    }

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

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