<?php

namespace App\Filament\Admin\Resources\WalletTransactions\Schemas;

use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Auth;

class WalletTransactionForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([

                // Payment Method Type Enum
                Select::make('pm_type')
                    ->label('Payment Method')
                    ->options([
                        // 'wallet' => 'Wallet',
                        'stripe' => 'Stripe',
                    ])
                    ->required()
                    ->default('stripe')
                    ->native(false),

                // Transaction Type Enum
                Select::make('type')
                    ->label('Transaction Type')
                    ->options([
                        'credit' => 'Credit',
                        // 'debit' => 'Debit',
                    ])->default('credit')
                    ->required()
                    ->native(false),

                // Amount
                TextInput::make('amount')
                    ->label('Amount by $')
                    ->required()
                    ->numeric()

                    ->step('0.01'),

                // Wallet Relationship
                Select::make('wallet_id')
                    ->label('Wallet')
                    ->relationship('wallet.user', 'name')
                    ->searchable()
                    ->preload()
                    ->required()
                    ->native(false),

                // User Relationship
                Select::make('user_id')
                    ->label('User')
                    ->relationship('user', 'name')
                    ->default(fn() => Auth::id())
                    ->disabled()
                    ->dehydrated(true) // VERY IMPORTANT
                    ->required()
                    ->native(false),
            ]);
    }
}
