<?php

namespace App\Filament\Resources\PaymentFines\Tables;

use Filament\Tables;
use Filament\Tables\Table;

class PaymentFinesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('contract.contract_number')
                    ->label('Hợp đồng')
                    ->searchable()
                    ->sortable(),

                Tables\Columns\TextColumn::make('amount')
                    ->label('Số tiền phạt')
                    ->money('VND')
                    ->sortable(),

                Tables\Columns\TextColumn::make('reason')
                    ->label('Lý do')
                    ->searchable(),

                Tables\Columns\TextColumn::make('due_date')
                    ->label('Hạn nộp')
                    ->date('d/m/Y')
                    ->sortable(),

                Tables\Columns\TextColumn::make('paid_date')
                    ->label('Ngày nộp')
                    ->date('d/m/Y')
                    ->placeholder('Chưa nộp')
                    ->color(fn ($state) => $state ? 'success' : 'danger'),
            ])
            ->filters([
                Tables\Filters\Filter::make('unpaid')
                    ->label('Chưa nộp')
                    ->query(fn ($query) => $query->whereNull('paid_date')),
            ])
            ->defaultSort('due_date', 'desc');
    }
}
