<?php

namespace App\Filament\Resources\Agents\Tables;

use Filament\Tables\Table;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;

class AgentsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('agent_id')
                    ->label('ID NO')
                    ->searchable()
                    ->sortable()
                    ->weight('bold'),

                TextColumn::make('agent_type')
                    ->label('AGENT TYPE')
                    ->badge()
                    ->color('warning')
                    ->searchable(),

                TextColumn::make('whatsapp_link')
                    ->label('WHATSAPP')
                    ->formatStateUsing(fn ($state) => $state ? 'WhatsApp' : '-')
                    ->url(fn ($record) => $record->whatsapp_link)
                    ->badge()
                    ->color('success')
                    ->openUrlInNewTab(),

                TextColumn::make('phone_number')
                    ->label('PHONE / WA')
                    ->url(fn ($record) => $record->phone_link)
                    ->color('success')
                    ->weight('bold')
                    ->searchable()
                    ->openUrlInNewTab(),

                TextColumn::make('complaint_link')
                    ->label('COMPLAINT')
                    ->formatStateUsing(fn ($state) => $state ? 'অভিযোগ' : '-')
                    ->url(fn ($record) => $record->complaint_link)
                    ->badge()
                    ->color('danger')
                    ->openUrlInNewTab(),
            ])
            ->filters([
                //
            ])
            ->actions([
                EditAction::make(),
                DeleteAction::make(),
            ])
            ->bulkActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}