<?php

namespace App\Filament\Resources\Galleries\Tables;

use Filament\Actions\Action;
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 GalleriesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('title')
                    ->label('Titel')
                    ->sortable()
                    ->searchable(),
                IconColumn::make('allow_ai_styles')
                    ->label('AI-Stile')
                    ->boolean(),
                IconColumn::make('allow_print')
                    ->label('Drucken')
                    ->boolean(),
                IconColumn::make('require_password')
                    ->label('Passwort')
                    ->boolean(),
                TextColumn::make('expires_at')
                    ->label('Läuft ab')
                    ->dateTime()
                    ->sortable(),
                TextColumn::make('created_at')
                    ->label('Erstellt am')
                    ->dateTime('d.m.Y H:i')
                    ->sortable(),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
                Action::make('link_details')
                    ->label('Link-Details')
                    ->icon('heroicon-o-link')
                    ->modalHeading('Link-Details')
                    ->modalContent(fn ($record) => view('filament.components.gallery-link-modal', [
                        'record' => $record,
                        'url' => route('gallery.show', $record),
                    ]))
                    ->modalSubmitAction(false)
                    ->modalCancelAction(false),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
