<?php

namespace App\Filament\Resources\Infrastructures\Tables;

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

class InfrastructuresTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('typeInfrastructure.id')
                    ->searchable(),
                TextColumn::make('nombre_movais')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('nombre_moyens')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('nombre_bons')
                    ->numeric()
                    ->sortable(),
                TextColumn::make('annee.id')
                    ->searchable(),
                TextColumn::make('etablissement.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(InfrastructureImport::class),
                ExportExcelAction::makeExport(InfrastructureExport::class, 'infrastructures_export.xlsx'),
                DownloadTemplateAction::makeTemplate('infrastructure', 'template_infrastructures.xlsx'),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
