<?php

namespace App\Filament\Resources\Rapports\Tables;

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

class RapportsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('date_inspection')
                    ->date()
                    ->sortable(),
                TextColumn::make('classe_visitee')
                    ->searchable(),
                TextColumn::make('nombre_eleve')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('present')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('horaire')
                    ->searchable(),
                TextColumn::make('passation')
                    ->searchable(),
                TextColumn::make('titre_lecon')
                    ->searchable(),
                TextColumn::make('deroulement')
                    ->searchable(),
                TextColumn::make('appreciation_generale')
                    ->searchable(),
                TextColumn::make('numero_ordre')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('note')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('etablissement.id')
                    ->searchable(),
                TextColumn::make('professeur.id')
                    ->searchable(),
                TextColumn::make('inspecteur.id')
                    ->searchable(),
                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(RapportImport::class),
                ExportExcelAction::makeExport(RapportExport::class, 'rapports_export.xlsx'),
                DownloadTemplateAction::makeTemplate('rapport', 'template_rapports.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
