<?php

declare(strict_types=1);

namespace App\Filament\Resources\Links\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\Table;

class LinksTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')
                    ->label(__('link.name'))
                    ->searchable(),
                TextColumn::make('url')
                    ->label(__('link.url'))
                    ->searchable()
                    ->limit(40)
                    ->openUrlInNewTab(),
                TextColumn::make('note')
                    ->label(__('link.note'))
                    ->searchable()
                    ->limit(30),
                TextColumn::make('display_order')
                    ->label(__('link.display_order'))
                    ->numeric()
                    ->sortable(),
                IconColumn::make('visible')
                    ->label(__('link.visible'))
                    ->boolean(),
                TextColumn::make('created_at')
                    ->label(__('link.created_at'))
                    ->dateTime('Y-m-d')
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('updated_at')
                    ->label(__('link.updated_at'))
                    ->dateTime('Y-m-d')
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->recordUrl(null)
            ->recordAction(null)
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
