<?php

namespace App\Filament\Resources\Monitoring\IssueManagements\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\SelectFilter;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;

class IssueManagementTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('mediaMonitoring.title')
                    ->label('Judul Berita')
                    ->limit(30)
                    ->searchable()
                    ->sortable(),

                TextColumn::make('issue')
                    ->label('Isu')
                    ->badge()
                    ->searchable()
                    ->sortable(),

                TextColumn::make('response')
                    ->label('Respon')
                    ->badge()
                    ->searchable()
                    ->sortable(),

                TextColumn::make('location.name')
                    ->label('Lokasi')
                    ->searchable()
                    ->sortable(),

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

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

                SelectFilter::make('issue')
                    ->label('Filter Isu')
                    ->options(\App\Enums\IssueSentiment::class)
                    ->native(false),

                SelectFilter::make('response')
                    ->label('Filter Respon')
                    ->options(\App\Enums\IssueSentiment::class)
                    ->native(false),
            ])
            ->recordActions([
                EditAction::make(),

                DeleteAction::make(),

                RestoreAction::make(),

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