<?php

namespace App\Filament\Resources\ApiRequests\Pages;

use App\Filament\Resources\ApiRequests\ApiRequestResource;
use Filament\Actions\EditAction;
use Filament\Infolists\Components\KeyValueEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\Pages\ViewRecord;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class ViewApiRequest extends ViewRecord
{
    protected static string $resource = ApiRequestResource::class;

    protected function getHeaderActions(): array
    {
        return [
            EditAction::make(),
        ];
    }

    public function infolist(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Request Details')
                    ->schema([
                        TextEntry::make('website.name')
                            ->label('Website'),
                        TextEntry::make('registration_number')
                            ->label('Registration Number')
                            ->copyable()
                            ->badge()
                            ->color('primary'),
                        TextEntry::make('ip_address')
                            ->label('IP Address')
                            ->copyable(),
                        TextEntry::make('response_status')
                            ->label('Response Status')
                            ->badge(),
                        TextEntry::make('created_at')
                            ->label('Request Time')
                            ->dateTime(),
                    ])
                    ->columns(2),
                Section::make('Contact Data')
                    ->schema([
                        KeyValueEntry::make('contact_data')
                            ->label('')
                            ->columnSpanFull(),
                    ])
                    ->collapsed()
                    ->collapsible(),
            ]);
    }
}
