<?php

namespace App\Filament\Resources\Reformes\Tables;

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

class ReformesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('libelle')
                    ->searchable(),
                TextColumn::make('date_debut')
                    ->date()
                    ->sortable(),
                TextColumn::make('annee_debut')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('annee_fin')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('ordre_min')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('ordre_max')
                    ->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(ReformeImport::class),
                ExportExcelAction::makeExport(ReformeExport::class, 'reformes_export.xlsx'),
                DownloadTemplateAction::makeTemplate('reforme', 'template_reformes.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
