<?php

namespace App\Filament\Resources\ModerationCases\Schemas;

use App\Models\ModerationCase;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class ModerationCaseInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make(__('admin.moderation_cases.sections.case'))
                    ->columns(3)
                    ->schema([
                        TextEntry::make('id')
                            ->label(__('admin.moderation_cases.fields.id'))
                            ->copyable(),
                        TextEntry::make('status')
                            ->label(__('admin.moderation_cases.fields.status'))
                            ->badge(),
                        TextEntry::make('reports_count')
                            ->label(__('admin.moderation_cases.fields.reports_count')),
                        TextEntry::make('threshold')
                            ->label(__('admin.moderation_cases.fields.threshold')),
                        TextEntry::make('threshold_notified_at')
                            ->label(__('admin.moderation_cases.fields.threshold_notified_at'))
                            ->dateTime()
                            ->placeholder(__('admin.moderation_cases.placeholders.empty')),
                        TextEntry::make('assignedTo.name')
                            ->label(__('admin.moderation_cases.fields.assigned_to'))
                            ->placeholder(__('admin.moderation_cases.placeholders.empty')),
                    ]),
                Section::make(__('admin.moderation_cases.sections.target'))
                    ->columns(3)
                    ->schema([
                        TextEntry::make('target_type')
                            ->label(__('admin.moderation_cases.fields.target_type'))
                            ->state(fn (ModerationCase $record): string => $record->targetLabel())
                            ->badge(),
                        TextEntry::make('target_title')
                            ->label(__('admin.moderation_cases.fields.target_title'))
                            ->state(fn (ModerationCase $record): string => $record->targetTitle()),
                        TextEntry::make('caseable_id')
                            ->label(__('admin.moderation_cases.fields.caseable_id'))
                            ->copyable(),
                    ]),
                Section::make(__('admin.moderation_cases.sections.resolution'))
                    ->columns(2)
                    ->schema([
                        TextEntry::make('resolvedBy.name')
                            ->label(__('admin.moderation_cases.fields.resolved_by'))
                            ->placeholder(__('admin.moderation_cases.placeholders.empty')),
                        TextEntry::make('resolved_at')
                            ->label(__('admin.moderation_cases.fields.resolved_at'))
                            ->dateTime()
                            ->placeholder(__('admin.moderation_cases.placeholders.empty')),
                        TextEntry::make('resolution_note')
                            ->label(__('admin.moderation_cases.fields.resolution_note'))
                            ->placeholder(__('admin.moderation_cases.placeholders.empty'))
                            ->columnSpanFull(),
                    ]),
                Section::make(__('admin.moderation_cases.sections.metadata'))
                    ->columns(2)
                    ->schema([
                        TextEntry::make('created_at')
                            ->label(__('admin.moderation_cases.fields.created_at'))
                            ->dateTime(),
                        TextEntry::make('updated_at')
                            ->label(__('admin.moderation_cases.fields.updated_at'))
                            ->dateTime(),
                    ]),
            ]);
    }
}
