<?php

declare(strict_types=1);

namespace App\Filament\Resources\Attachments\Tables;

use App\Filament\Support\AdminTable;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class AttachmentsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                AdminTable::ellipsis(
                    TextColumn::make('article.title')
                        ->label(__('admin.fields.article'))
                        ->searchable(),
                ),
                TextColumn::make('disk')
                    ->label(__('admin.fields.disk'))
                    ->searchable(),
                AdminTable::ellipsis(
                    TextColumn::make('path')
                        ->label(__('admin.fields.path'))
                        ->searchable(),
                ),
                TextColumn::make('thumb_path')
                    ->label(__('admin.fields.thumb_path'))
                    ->searchable()
                    ->toggleable(isToggledHiddenByDefault: true),
                AdminTable::ellipsis(
                    TextColumn::make('filename')
                        ->label(__('admin.fields.filename'))
                        ->searchable(),
                ),
                TextColumn::make('mime')
                    ->label(__('admin.fields.mime'))
                    ->searchable(),
                TextColumn::make('size')
                    ->label(__('admin.fields.size'))
                    ->numeric()
                    ->sortable(),
                TextColumn::make('checksum')
                    ->label(__('admin.fields.checksum'))
                    ->searchable(),
                TextColumn::make('visibility')
                    ->label(__('admin.fields.visibility'))
                    ->searchable(),
                TextColumn::make('legacy_filepath')
                    ->label(__('admin.fields.legacy_filepath'))
                    ->searchable(),
                TextColumn::make('synced_at')
                    ->label(__('admin.fields.synced_at'))
                    ->dateTime()
                    ->sortable(),
                TextColumn::make('downloads')
                    ->label(__('admin.fields.downloads'))
                    ->numeric()
                    ->sortable(),
                TextColumn::make('created_at')
                    ->label(__('admin.fields.created_at'))
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
                TextColumn::make('updated_at')
                    ->label(__('admin.fields.updated_at'))
                    ->dateTime()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
