<?php

namespace App\Filament\Resources\ModerationCases\Schemas;

use App\Enums\ModerationCaseStatus;
use Filament\Forms\Components\DateTimePicker;
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 ModerationCaseForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make(__('admin.moderation_cases.sections.case'))
                    ->columns(2)
                    ->schema([
                        Select::make('status')
                            ->label(__('admin.moderation_cases.fields.status'))
                            ->options(ModerationCaseStatus::class)
                            ->required(),
                        Select::make('assigned_to')
                            ->label(__('admin.moderation_cases.fields.assigned_to'))
                            ->relationship('assignedTo', 'name')
                            ->searchable()
                            ->preload(),
                        TextInput::make('reports_count')
                            ->label(__('admin.moderation_cases.fields.reports_count'))
                            ->numeric()
                            ->disabled()
                            ->dehydrated(false),
                        TextInput::make('threshold')
                            ->label(__('admin.moderation_cases.fields.threshold'))
                            ->numeric()
                            ->disabled()
                            ->dehydrated(false),
                    ]),
                Section::make(__('admin.moderation_cases.sections.target'))
                    ->columns(2)
                    ->schema([
                        TextInput::make('caseable_type')
                            ->label(__('admin.moderation_cases.fields.target_type'))
                            ->disabled()
                            ->dehydrated(false),
                        TextInput::make('caseable_id')
                            ->label(__('admin.moderation_cases.fields.caseable_id'))
                            ->disabled()
                            ->dehydrated(false),
                    ]),
                Section::make(__('admin.moderation_cases.sections.resolution'))
                    ->columns(2)
                    ->schema([
                        DateTimePicker::make('resolved_at')
                            ->label(__('admin.moderation_cases.fields.resolved_at')),
                        Select::make('resolved_by')
                            ->label(__('admin.moderation_cases.fields.resolved_by'))
                            ->relationship('resolvedBy', 'name')
                            ->searchable()
                            ->preload(),
                        Textarea::make('resolution_note')
                            ->label(__('admin.moderation_cases.fields.resolution_note'))
                            ->rows(4)
                            ->columnSpanFull(),
                    ]),
            ]);
    }
}
