<?php

declare(strict_types=1);

namespace App\Filament\Resources\SupportTickets\Schemas;

use App\Models\SupportTicket;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class SupportTicketForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Section::make('تیکت')
                ->schema([
                    TextInput::make('code')->label('کد')->disabled(),
                    TextInput::make('title')->label('عنوان')->disabled(),
                    Select::make('category')->label('دسته')->options(SupportTicket::categoryOptions())->disabled(),
                    Textarea::make('body')->label('متن')->disabled()->rows(4),
                    Select::make('status')
                        ->label('وضعیت')
                        ->options(SupportTicket::statusOptions())
                        ->disabled(),
                    Textarea::make('close_reason')
                        ->label('دلیل بستن')
                        ->disabled()
                        ->rows(2)
                        ->visible(fn (?SupportTicket $record) => $record?->status === SupportTicket::STATUS_CLOSED),
                ])
                ->columns(1),
        ]);
    }
}
