<?php

namespace App\Filament\Resources\VehicleRecords\Pages;

use App\Filament\Resources\VehicleRecords\VehicleRecordResource;
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 ViewVehicleRecord extends ViewRecord
{
    protected static string $resource = VehicleRecordResource::class;

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

    public function infolist(Schema $schema): Schema
    {
        return $schema
            ->columns(1)
            ->components([
                Section::make('Vehicle Details')
                    ->schema([
                        TextEntry::make('registration_number')
                            ->label('Registration Number')
                            ->copyable()
                            ->badge()
                            ->color('primary'),
                        TextEntry::make('created_at')
                            ->label('First Cached')
                            ->dateTime(),
                        TextEntry::make('updated_at')
                            ->label('Last Updated')
                            ->dateTime(),
                    ])
                    ->columns(3),
                Section::make('Vehicle Data')
                    ->schema([
                        KeyValueEntry::make('data')
                            ->label('')
                            ->columnSpanFull(),
                    ])
                    ->collapsible(),
            ]);
    }
}
