<?php

declare(strict_types=1);

namespace App\Filament\Resources\MediaCategories\Tables;

use App\Models\MediaCategory;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class MediaCategoriesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')->label('نام')->searchable()->sortable(),
                TextColumn::make('parent.name')->label('شاخه اصلی')->placeholder('—'),
                TextColumn::make('type')
                    ->label('نوع')
                    ->formatStateUsing(fn (?string $state) => MediaCategory::typeOptions()[$state] ?? $state ?? '-'),
                TextColumn::make('sort_order')->label('ترتیب')->sortable(),
            ])
            ->defaultSort('sort_order')
            ->recordActions([
                \Filament\Actions\EditAction::make(),
            ]);
    }
}
