<?php

namespace App\Filament\Resources\ResumeReports;

use App\Filament\Resources\ResumeReports\Pages\ListResumeReports;
use App\Models\ResumeReport;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;

class ResumeReportResource extends Resource
{
    protected static ?string $model = ResumeReport::class;

    protected static string|BackedEnum|null $navigationIcon = Heroicon::DocumentCheck;

    protected static ?string $navigationLabel = 'Resume Reports';

    protected static string|\UnitEnum|null $navigationGroup = 'Platform';

    protected static ?int $navigationSort = 30;

    public static function form(Schema $schema): Schema
    {
        return $schema;
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('user.email')
                    ->label('User')
                    ->searchable()
                    ->sortable(),

                TextColumn::make('original_filename')
                    ->searchable(),

                TextColumn::make('status')
                    ->badge()
                    ->sortable(),

                TextColumn::make('ats_score')
                    ->sortable(),

                TextColumn::make('remote_readiness_score')
                    ->label('Remote score')
                    ->sortable(),

                TextColumn::make('analyzed_at')
                    ->dateTime()
                    ->sortable(),

                TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable(),
            ])
            ->filters([
                SelectFilter::make('status')
                    ->options([
                        ResumeReport::STATUS_PENDING => 'Pending',
                        ResumeReport::STATUS_PROCESSING => 'Processing',
                        ResumeReport::STATUS_COMPLETED => 'Completed',
                        ResumeReport::STATUS_FAILED => 'Failed',
                    ]),
            ])
            ->defaultSort('created_at', 'desc');
    }

    public static function getPages(): array
    {
        return [
            'index' => ListResumeReports::route('/'),
        ];
    }
}
