<?php

declare(strict_types=1);

namespace App\Filament\Resources\Posts\Schemas;

use App\Enums\Status;
use App\Models\Post;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class PostForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Group::make()
                ->schema([
                    Section::make('اطلاعات اصلی')
                        ->schema([
                            \App\Filament\Components\Form\TitleTextInput::create()->required()->columnSpan(8),
                            \App\Filament\Components\Form\SlugTextInput::create()->required()->columnSpan(4),
                            \App\Filament\Components\Form\ExcerptTextarea::create()->columnSpan(12),
                            \App\Filament\Components\Form\DescTextarea::create()->required()->rows(8),
                            \App\Filament\Components\Form\AuthorSelect::create()->required()->columnSpan(6),
                            \App\Filament\Components\Form\TimeToReadTextInput::create()->required()->columnSpan(6),
                            \App\Filament\Components\Form\CategoriesSelect::create(Post::class)->columnSpan(12),
                            \App\Filament\Components\Form\TagsTagsInput::create(Post::class)->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    Section::make('رسانه')
                        ->schema([
                            \App\Filament\Components\Form\ImageFileUpload::create(),
                            \App\Filament\Components\Form\VideoFileUpload::create(),
                            \App\Filament\Components\Form\GalleryFileUpload::create(),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                ])
                ->columns(12)
                ->columnSpan(8),
            Group::make()
                ->schema([
                    Section::make('انتشار')
                        ->schema([
                            Select::make('status')
                                ->label('وضعیت')
                                ->options(collect(Status::get())->mapWithKeys(fn ($state) => [$state['value'] => $state['label']])->all())
                                ->default(Status::PUBLISHED->value)
                                ->required()
                                ->columnSpan(12),
                            DateTimePicker::make('publish_at')
                                ->label('تاریخ انتشار')
                                ->jalali()
                                ->seconds(false)
                                ->columnSpan(12),
                            \App\Filament\Components\Form\IsFeaturedToggle::create()->columnSpan(12),
                            \App\Filament\Components\Form\ViewsTextInput::create()->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    Section::make('سئو')
                        ->schema([
                            \App\Filament\Components\Form\MetaTitleTextInput::create()->columnSpan(12),
                            \App\Filament\Components\Form\MetaDescTextarea::create()->columnSpan(12),
                            \App\Filament\Components\Form\MetaKeywordsTagsInput::create()->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    Section::make('اطلاعات سیستم')
                        ->schema([
                            \App\Filament\Components\Form\CreatedBySelect::create()->required(),
                            \App\Filament\Components\Form\UpdatedBySelect::create(),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                ])
                ->columns(12)
                ->columnSpan(4),
        ])
            ->columns(12);
    }
}
