<?php

namespace App\Filament\Resources\DeliveryPartners\Schemas;

use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;

class DeliveryPartnerForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                TextInput::make('application_id')
                    ->required()
                    ->numeric(),
                TextInput::make('name')
                    ->required(),
                TextInput::make('phone')
                    ->tel()
                    ->required(),
                TextInput::make('cnic')
                    ->required(),
                TextInput::make('profile_photo')
                    ->default(null),
                TextInput::make('password')
                    ->password()
                    ->required(),
                TextInput::make('pin')
                    ->default(null),
                Select::make('vehicle_type')
                    ->options(['motorcycle' => 'Motorcycle', 'car' => 'Car', 'truck' => 'Truck', 'tractor' => 'Tractor'])
                    ->default('motorcycle')
                    ->required(),
                TextInput::make('vehicle_make')
                    ->default(null),
                TextInput::make('vehicle_model')
                    ->default(null),
                TextInput::make('vehicle_plate')
                    ->default(null),
                Toggle::make('is_online')
                    ->required(),
                TextInput::make('last_lat')
                    ->numeric()
                    ->default(null),
                TextInput::make('last_lng')
                    ->numeric()
                    ->default(null),
                DateTimePicker::make('last_location_at'),
                DateTimePicker::make('went_offline_at'),
                TextInput::make('total_deliveries')
                    ->required()
                    ->numeric()
                    ->default(0),
                TextInput::make('accepted_count')
                    ->required()
                    ->numeric()
                    ->default(0),
                TextInput::make('declined_count')
                    ->required()
                    ->numeric()
                    ->default(0),
                TextInput::make('consecutive_declines')
                    ->required()
                    ->numeric()
                    ->default(0),
                TextInput::make('completion_rate')
                    ->required()
                    ->numeric()
                    ->default(100.0),
                TextInput::make('acceptance_rate')
                    ->required()
                    ->numeric()
                    ->default(100.0),
                TextInput::make('rating_average')
                    ->required()
                    ->numeric()
                    ->default(0.0),
                TextInput::make('rating_count')
                    ->required()
                    ->numeric()
                    ->default(0),
                Toggle::make('cooldown_active')
                    ->required(),
                DateTimePicker::make('cooldown_until'),
                TextInput::make('wallet_balance')
                    ->required()
                    ->numeric()
                    ->default(0.0),
                TextInput::make('pending_cod')
                    ->required()
                    ->numeric()
                    ->default(0.0),
                Select::make('payout_method')
                    ->options(['easypaisa' => 'Easypaisa', 'jazzcash' => 'Jazzcash', 'bank' => 'Bank'])
                    ->default(null),
                TextInput::make('payout_account')
                    ->default(null),
                Select::make('status')
                    ->options(['active' => 'Active', 'suspended' => 'Suspended', 'blacklisted' => 'Blacklisted'])
                    ->default('active')
                    ->required(),
                Textarea::make('suspension_reason')
                    ->default(null)
                    ->columnSpanFull(),
            ]);
    }
}
