<?php

namespace App\Filament\Resources\CashRecords\Schemas;

use App\Models\CashCategory;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;

class CashRecordForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Select::make('category_id')->label('Kategori')
                ->options(
                    CashCategory::all()->mapWithKeys(fn ($c) => [
                        $c->id => $c->name . ' (' . ucfirst($c->type) . ')'
                    ])
                )
                ->required(),
            TextInput::make('amount')->label('Jumlah (Rp)')->numeric()->required()
                ->helperText('< Rp500.000: langsung | Rp500.000–2.000.000: perlu approval ketua | > Rp2.000.000: perlu voting')
                ->live(),
            Textarea::make('description')->label('Keterangan')->required()->columnSpanFull(),
            DatePicker::make('date')->label('Tanggal')->required(),
        ]);
    }
}
