<?php

declare(strict_types=1);

namespace App\Filament\Resources\Discussions\Schemas;

use App\Filament\Support\SelectOptionLabels;

use App\Models\Discussion;
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 DiscussionForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Section::make('بحث')
                ->schema([
                    Select::make('project_id')
                        ->label('پروژه')
                        ->relationship('project', 'name')
                        ->getOptionLabelFromRecordUsing(fn ($record) => SelectOptionLabels::project($record))
                        ->searchable()
                        ->preload(),
                    TextInput::make('title')->label('نام بحث')->required()->maxLength(255),
                    TextInput::make('hashtag')->label('هشتگ')->maxLength(100)->placeholder('#موضوع'),
                    Select::make('status')
                        ->label('وضعیت')
                        ->options([
                            Discussion::STATUS_ACTIVE => 'فعال',
                            Discussion::STATUS_ENDED => 'پایان‌یافته',
                            Discussion::STATUS_DELETED => 'حذف شده',
                        ])
                        ->default(Discussion::STATUS_ACTIVE),
                    Textarea::make('initial_message')->label('پیام اولیه')->rows(4),
                ])
                ->columns(1),
        ]);
    }
}
