<?php

namespace App\Filament\Resources\ApiKeys\Schemas;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Hidden;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Auth;

class ApiKeyForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Hidden::make('user_id')
                    ->default(fn () => Auth::id()),
                TextInput::make('name')
                    ->required()
                    ->maxLength(255)
                    ->columnSpanFull(),
                CheckboxList::make('abilities')
                    ->options([
                        'payment:checkout' => 'payment:checkout',
                        'payment:verify' => 'payment:verify',
                        'payment:refund' => 'payment:refund',
                    ])
                    ->columns(2)
                    ->columnSpanFull()
                    ->required(),
                DatePicker::make('expires_at')
                    ->columnSpanFull(),
                Toggle::make('is_active')
                    ->default(true)
                    ->required()
                    ->columnSpanFull(),
            ]);
    }
}
