<?php

namespace App\Filament\Resources\Professeurs\Tables;

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

class ProfesseursTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('nomar')
                    ->searchable(),
                TextColumn::make('nomfr')
                    ->searchable(),
                TextColumn::make('matricule')
                    ->searchable(),
                TextColumn::make('nni')
                    ->searchable(),
                TextColumn::make('date_naissance')
                    ->date()
                    ->sortable(),
                TextColumn::make('date_recritement')
                    ->date()
                    ->sortable(),
                TextColumn::make('lieu_naissance_ar')
                    ->searchable(),
                TextColumn::make('lieu_naissance_fr')
                    ->searchable(),
                TextColumn::make('discipline_origine')
                    ->searchable(),
                TextColumn::make('contact')
                    ->searchable(),
                TextColumn::make('statut_id')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('cycle_id')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('photo')
                    ->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(ProfesseurImport::class),
                ExportExcelAction::makeExport(ProfesseurExport::class, 'professeurs_export.xlsx'),
                DownloadTemplateAction::makeTemplate('professeur', 'template_professeurs.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
