<?php

namespace App\Filament\Admin\Resources\Blogs\Schemas;

use Filament\Actions\Action;
use Filament\Infolists\Components\IconEntry;
use Filament\Infolists\Components\ImageEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class BlogInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Main Information')
                    ->schema([
                        Grid::make(2)
                            ->schema([
                                TextEntry::make('en_title')
                                    ->placeholder('-'),

                                TextEntry::make('fa_title')
                                    ->placeholder('-'),

                                ImageEntry::make('thumbnail')
                                    ->label('Thumbnail')
                                 ->disk('public')
                    ->visibility('public')
                                    ->placeholder('-'),

                                TextEntry::make('user.name')
                                    ->label('User'),

                                IconEntry::make('is_active')
                                    ->boolean(),

                                IconEntry::make('is_featured')
                                    ->boolean(),
                            ]),
                    ]),



                Section::make('Descriptions')
                    ->schema([
                        Grid::make(1)
                            ->schema([
                                TextEntry::make('en_description')
                                ->html()
                                    ->placeholder('-'),

                                TextEntry::make('fa_description')
                                ->html()

                                    ->placeholder('-'),
                            ]),
                    ])
                    ->columnSpanFull(),
                             Section::make('Status Actions')
                    ->schema([
                        Grid::make(2)
                            ->schema([
                                Action::make('toggleActive')
                                    ->label('Toggle Active')
                                    ->action(fn ($record) => $record->update([
                                        'is_active' => ! $record->is_active,
                                    ])),

                                Action::make('toggleFeatured')
                                    ->label('Toggle Featured')
                                    ->action(fn ($record) => $record->update([
                                        'is_featured' => ! $record->is_featured,
                                    ])),
                            ]),
                    ]),

                Section::make('Timestamps')
                    ->schema([
                        Grid::make(2)
                            ->schema([
                                TextEntry::make('created_at')
                                    ->dateTime()
                                    ->placeholder('-'),

                                TextEntry::make('updated_at')
                                    ->dateTime()
                                    ->placeholder('-'),
                            ]),
                    ]),
            ]);
    }
}
