<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\Filament\Admin\Resources\Users\Tables;

use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Support\Colors\Color;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class UsersTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')
                    ->label('Name')
                    ->searchable(),
                TextColumn::make('email')
                    ->label('Email')
                    ->searchable(),
                TextColumn::make('email_verified_at')
                    ->label('geprüft am')
                    ->dateTime()
                    ->sortable(),
                TextColumn::make('created_at')
                    ->label('erstellt am')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('updated_at')
                    ->label('aktualisiert am')
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
            // customize filter layout
            ->filtersTriggerAction(
                fn (Action $action) => $action
                    ->button()
                    ->label('Filter'),
            )
            ->recordActions([
                ViewAction::make()
                    ->color(Color::Sky),
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ])

            // disable the default edit action and use ViewAction instead
//            ->recordAction(ViewAction::class)
//            ->recordUrl(null)

            // empty state heading and description
            ->emptyStateHeading('Keine Benutzer verfügbar')
            ->emptyStateDescription('Wenn sie einen Benutzer erstellt haben, wird dieser hier angezeigt.')

            ;
    }
}
