<?php

namespace App\Filament\Resources\CashCategories\Tables;

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

class CashCategoriesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')->label('Nama')->searchable(),
                TextColumn::make('type')->label('Tipe')
                    ->badge()
                    ->color(fn ($state) => $state === 'pemasukan' ? 'success' : 'danger')
                    ->formatStateUsing(fn ($state) => ucfirst($state)),
                TextColumn::make('records_count')->counts('records')->label('Transaksi'),
            ])
            ->recordActions([EditAction::make()])
            ->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
    }
}
