<?php

namespace App\Filament\Resources\Vehicles\Tables;

use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;

class VehiclesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('driver.name')
                    ->label('Owner / Driver')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('plate')
                    ->label('Number Plate')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('make')
                    ->label('Make')
                    ->searchable(),

                TextColumn::make('model')
                    ->label('Model')
                    ->searchable(),

                TextColumn::make('year')
                    ->label('Year')
                    ->numeric()
                    ->sortable(),

                TextColumn::make('color')
                    ->label('Color'),

                TextColumn::make('seat_capacity')
                    ->label('Seats')
                    ->numeric()
                    ->sortable(),

                IconColumn::make('is_verified')
                    ->label('Verified')
                    ->boolean(),

                TextColumn::make('created_at')
                    ->label('Registered')
                    ->date('d M Y')
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->defaultSort('created_at', 'desc')
            ->filters([
                TernaryFilter::make('is_verified')->label('Verified vehicles'),
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
