<?php

namespace App\Filament\Resources\Monitoring\MediaMonitorings\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 MediaMonitoringsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('code')
                    ->label('Kode')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('media_name')
                    ->label('Nama media')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('title')
                    ->label('Judul')
                    ->limit(30)
                    ->searchable()
                    ->sortable(),

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

                TextColumn::make('writter')
                    ->label('Penulis')
                    ->searchable()
                    ->sortable(),

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

                TextColumn::make('news_page')
                    ->label('Halaman Berita')
                    ->searchable()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),

                TextColumn::make('influencer')
                    ->searchable()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),

                TextColumn::make('keyword')
                    ->searchable()
                    ->sortable()
                    ->toggleable(isToggledHiddenByDefault: true),

                TextColumn::make('themes.name')
                    ->label('Tema')
                    ->searchable()
                    ->sortable()
                    ->wrap()
                    ->badge(),

                TextColumn::make('release_date')
                    ->label('Tgl Rilis')
                    ->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('Monitoring Media'),
                ]),
            ])
            ->emptyStateIcon(Heroicon::ClipboardDocumentCheck)
            ->emptyStateDescription('Setelah Anda membubat data pertama, maka akan muncul disini.')
            ->defaultSort('created_at', 'desc')
            ->deferFilters(false);
    }
}
