<?php

namespace App\Filament\Resources\MemberDues\Tables;

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

class MemberDuesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('user.name')->label('Anggota')->searchable()->sortable(),
                TextColumn::make('period')->label('Periode')->sortable(),
                TextColumn::make('amount')->label('Jumlah')->money('IDR')->sortable(),
                TextColumn::make('status')->label('Status')->badge()
                    ->color(fn ($state) => $state === 'lunas' ? 'success' : 'danger'),
                TextColumn::make('paid_at')->label('Tgl Bayar')->date('d M Y')->placeholder('-'),
                TextColumn::make('notes')->label('Catatan')->limit(30)->placeholder('-'),
            ])
            ->defaultSort('period', 'desc')
            ->filters([
                SelectFilter::make('status')->options(['lunas' => 'Lunas', 'belum' => 'Belum Lunas']),
            ])
            ->recordActions([EditAction::make()])
            ->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
    }
}
