<?php

declare(strict_types=1);

namespace App\Filament\Resources\MarketPrices\Schemas;

use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class MarketPriceForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Section::make('قیمت بازار')
                ->schema([
                    TextInput::make('label')->label('عنوان')->required()->maxLength(255),
                    TextInput::make('price')->label('قیمت (تومان)')->numeric()->required()->minValue(0),
                    TextInput::make('change')->label('تغییر (%)')->numeric()->step(0.01)->default(0),
                    Select::make('category_id')
                        ->label('دسته')
                        ->relationship('category', 'title')
                        ->searchable()
                        ->preload(),
                    Select::make('breed_id')
                        ->label('نژاد')
                        ->relationship('breed', 'name')
                        ->searchable()
                        ->preload(),
                    Select::make('province_id')
                        ->label('استان')
                        ->relationship('province', 'name')
                        ->searchable()
                        ->preload(),
                    Select::make('county_id')
                        ->label('شهرستان')
                        ->relationship('county', 'name')
                        ->searchable()
                        ->preload(),
                    DateTimePicker::make('recorded_at')->label('زمان ثبت قیمت')->jalali()->default(now()),
                ])->columns(2),
        ]);
    }
}
