<?php

namespace App\Filament\Resources\Progressions\Tables;

use App\Actions\DownloadTemplateAction;
use App\Actions\ExportExcelAction;
use App\Actions\ImportExcelAction;
use App\Imports\ProgressionImport;
use App\Exports\ProgressionExport;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class ProgressionsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('numero_lecon')
                    ->searchable(),
                TextColumn::make('chapitre')
                    ->searchable(),
                TextColumn::make('titre_lecon')
                    ->searchable(),
                TextColumn::make('numero_semaine')
                    ->searchable(),
                TextColumn::make('discipline_id')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('updated_at')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                ImportExcelAction::makeImport(ProgressionImport::class),
                ExportExcelAction::makeExport(ProgressionExport::class, 'progressions_export.xlsx'),
                DownloadTemplateAction::makeTemplate('progression', 'template_progressions.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
