<?php

namespace App\Filament\Resources\Monitoring\ContentRecaps\Tables;

use App\Filament\Actions\DefaultBulkActions;
use App\Filament\Columns\TimestampColumns;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Actions\ForceDeleteAction;
use Filament\Actions\RestoreAction;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;

class ContentRecapsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('title')
                    ->label('Judul')
                    ->searchable()
                    ->sortable()
                    ->wrap(),

                TextColumn::make('type')
                    ->label('Tipe')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('channel')
                    ->label('Kanal')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('social_media')
                    ->label('Media Sosial')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('classification.name')
                    ->label('Klasifikasi')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('link')
                    ->label('Tautan')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('posting_date')
                    ->label('Tgl Posting')
                    ->searchable()
                    ->sortable()
                    ->date('l, d F Y'),

                ...TimestampColumns::make(),
            ])
            ->filters([
                TrashedFilter::make()->native(false),
            ])
            ->recordActions([
                EditAction::make(),

                DeleteAction::make(),

                ForceDeleteAction::make(),

                RestoreAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    ...DefaultBulkActions::make('Rekap Konten'),
                ]),
            ])
            ->emptyStateIcon(Heroicon::ClipboardDocumentList)
            ->emptyStateDescription('Setelah Anda membubat data pertama, maka akan muncul disini.')
            ->defaultSort('created_at', 'desc')
            ->deferFilters(false);
    }
}
