<?php

namespace App\Filament\Resources\Leads\Tables;

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

class LeadsTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('email_phone')
                    ->label('Lead Contact')
                    ->searchable()
                    ->sortable()
                    ->weight('bold'),
                TextColumn::make('name')
                    ->searchable()
                    ->color('gray'),
                TextColumn::make('service_interest')
                    ->label('Service')
                    ->searchable()
                    ->placeholder('Not selected')
                    ->badge()
                    ->color('info'),
                TextColumn::make('status')
                    ->badge()
                    ->color(fn (string $state): string => match ($state) {
                        'new' => 'warning',
                        'contacted' => 'info',
                        'converted' => 'success',
                        'junk' => 'danger',
                        default => 'gray',
                    }),
                TextColumn::make('offer.title')
                    ->label('Offer Target')
                    ->placeholder('General Query'),
                TextColumn::make('created_at')
                    ->label('Captured At')
                    ->dateTime()
                    ->sortable(),
            ])
            ->filters([])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
