<?php

namespace App\Filament\Pages\Settings\General\Schemas;

use App\Filament\Support\CheerfulNotification;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class GeneralSettingsForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make(fn () => CheerfulNotification::getByKey('settings.general.basic_info.title'))
                    ->description(fn () => CheerfulNotification::getByKey('settings.general.basic_info.description'))
                    ->schema([
                        TextInput::make('site_name')
                            ->label('Nama')
                            ->placeholder('Simedkom')
                            ->autofocus()
                            ->autocomplete(false)
                            ->required()
                            ->maxLength(255),

                        Textarea::make('site_description')
                            ->label('Deskripsi')
                            ->placeholder('Aplikasi Sistem Media Komunikasi Kabupaten Purwakarta')
                            ->autocomplete(false)
                            ->required(),

                        Textarea::make('address')
                            ->label('Alamat')
                            ->placeholder('Jl. Laks. Laut RE. Martadinata No.47')
                            ->autocomplete(false)
                            ->rows(3)
                            ->required()
                            ->maxLength(255),

                        TextInput::make('site_email')
                            ->label('Alamat Surel')
                            ->placeholder('diskominfo@purwakartakab.go.id')
                            ->email()
                            ->required()
                            ->maxLength(255)
                            ->autocomplete(false),

                        TextInput::make('site_phone')
                            ->label('Nomor Telepon')
                            ->placeholder('(0264) 200222')
                            ->required()
                            ->maxLength(255)
                            ->autocomplete(false),

                        RichEditor::make('about_us')
                            ->label('Tentang Kami')
                            ->placeholder('...')
                            ->required()
                            ->columnSpanFull(),
                    ])->columnSpan(2),

                Section::make(fn () => CheerfulNotification::getByKey('settings.general.logo_icon.title'))
                    ->description(fn () => CheerfulNotification::getByKey('settings.general.logo_icon.description'))
                    ->schema([
                        FileUpload::make('site_logo')
                            ->label('Logo')
                            ->required()
                            ->image()
                            ->maxSize(1024 * 2)
                            ->helperText('Format yang diterima: JPEG, PNG, WEBP. Ukuran maksimum: 2 MB.')
                            ->directory('settings'),

                        FileUpload::make('site_icon')
                            ->label('Ikon')
                            ->required()
                            ->image()
                            ->maxSize(1024 * 1)
                            ->helperText('Format yang diterima: JPEG, PNG, ICO, WEBP. Ukuran maksimum: 1 MB.')
                            ->directory('settings'),
                    ])->columnSpan(1),
            ])
            ->columns(3);
    }
}
