<?php

namespace App\Filament\Resources\Niveaux\Tables;

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

class NiveauxTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('libelle')
                    ->searchable(),
                TextColumn::make('reforme.id')
                    ->searchable(),
                TextColumn::make('cycle_id')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('ordre')
                    ->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(NiveauImport::class),
                ExportExcelAction::makeExport(NiveauExport::class, 'niveaux_export.xlsx'),
                DownloadTemplateAction::makeTemplate('niveau', 'template_niveaux.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
