<?php

declare(strict_types=1);

namespace App\Filament\Resources\Logs\Tables;

use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Actions\ForceDeleteBulkAction;
use Filament\Actions\RestoreBulkAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;

class LogsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->defaultSort('created_at', 'desc')
            ->columns([
                TextColumn::make('event')->label('رویداد')->searchable()->sortable(),
                \App\Filament\Components\Table\UserTextColumn::create(),
                TextColumn::make('ip')->label('آی‌پی')->searchable()->toggleable(),
                TextColumn::make('priority')->label('اولویت')->numeric()->sortable()->toggleable(),
                TextColumn::make('location')->label('موقعیت')->searchable()->toggleable()->placeholder('-'),
                IconColumn::make('is_viewed')->label('مشاهده شده')->boolean(),
                TextColumn::make('count')->label('تعداد')->numeric()->sortable()->toggleable(),
                \App\Filament\Components\Table\CreatedByTextColumn::create(),
                \App\Filament\Components\Table\UpdatedByTextColumn::create(),
                \App\Filament\Components\Table\DeletedAtTextColumn::create(),
                \App\Filament\Components\Table\CreatedAtTextColumn::create(),
                \App\Filament\Components\Table\UpdatedAtTextColumn::create(),
            ])
            ->filters([
                TrashedFilter::make(),
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                    ForceDeleteBulkAction::make(),
                    RestoreBulkAction::make(),
                ]),
            ]);
    }
}
