<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpDictionaryTypes\Schemas;

use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class DberpDictionaryTypeForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make(__('dberp.sections.dictionary_type'))
                    ->schema([
                        TextInput::make('code')
                            ->label(__('dberp.fields.dict_type_code'))
                            ->required()
                            ->maxLength(64)
                            ->unique(ignoreRecord: true)
                            ->disabled()
                            ->helperText(__('dberp.dictionary_type_control.code_field_hint')),
                        TextInput::make('name')
                            ->label(__('dberp.fields.dict_type_name'))
                            ->required()
                            ->maxLength(255),
                        Textarea::make('description')
                            ->label(__('dberp.fields.dict_type_description'))
                            ->rows(2)
                            ->columnSpanFull(),
                        TextInput::make('sort_order')
                            ->label(__('dberp.fields.sort_order'))
                            ->numeric()
                            ->default(0)
                            ->required(),
                    ])
                    ->columns(2),
            ]);
    }
}
