<?php

namespace App\Filament\Resources\ModernizationPages\Tables;

use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;

class ModernizationPagesTable
{
    public static function configure(Table $table): Table
    {
        return $table->defaultSort('sort_order')->columns([
            TextColumn::make('title')->label('Seite')->searchable()->sortable(),
            TextColumn::make('parent.title')->label('Themenwelt')->placeholder('Hauptthema')->sortable(),
            TextColumn::make('kind')->label('Typ')->formatStateUsing(fn (string $state) => $state === 'category' ? 'Themenwelt' : 'Ratgeber'),
            TextColumn::make('sort_order')->label('Position')->sortable(),
            IconColumn::make('is_published')->label('Online')->boolean(),
        ])->filters([
            SelectFilter::make('kind')->label('Seitentyp')->options(['category' => 'Themenwelt', 'article' => 'Ratgeberartikel']),
            SelectFilter::make('parent_id')->label('Themenwelt')->relationship('parent', 'title'),
        ])->recordActions([
            EditAction::make()->label('Bearbeiten'),
        ]);
    }
}
