<?php

namespace Modules\Payment\Filament\Resources\Payments\Schemas;

use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Modules\Payment\Enums\PaymentStatus;

class PaymentInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Payment')
                    ->icon(Heroicon::OutlinedBanknotes)
                    ->schema([
                        Grid::make(4)
                            ->schema([
                                TextEntry::make('booking.booking_ref')
                                    ->label('Booking')
                                    ->icon(Heroicon::OutlinedTicket)
                                    ->copyable(),
                                TextEntry::make('gateway')
                                    ->icon(Heroicon::OutlinedCreditCard)
                                    ->badge(),
                                TextEntry::make('status')
                                    ->icon(Heroicon::OutlinedCheckCircle)
                                    ->badge()
                                    ->color(fn (PaymentStatus $state) => match ($state) {
                                        PaymentStatus::Pending => 'warning',
                                        PaymentStatus::Completed => 'success',
                                        PaymentStatus::Failed => 'danger',
                                    }),
                                TextEntry::make('amount')
                                    ->label('Amount')
                                    ->icon(Heroicon::OutlinedCurrencyDollar)
                                    ->money(fn ($record) => $record->currency)
                                    ->weight('bold'),
                            ]),
                    ]),
                Section::make('Timeline')
                    ->icon(Heroicon::OutlinedClock)
                    ->schema([
                        Grid::make(3)
                            ->schema([
                                TextEntry::make('gateway_transaction_id')
                                    ->label('Gateway Txn ID')
                                    ->icon(Heroicon::OutlinedHashtag)
                                    ->copyable()
                                    ->placeholder('—'),
                                TextEntry::make('initiated_at')
                                    ->icon(Heroicon::OutlinedPlayCircle)
                                    ->dateTime()
                                    ->placeholder('—'),
                                TextEntry::make('completed_at')
                                    ->icon(Heroicon::OutlinedFlag)
                                    ->dateTime()
                                    ->placeholder('—'),
                            ]),
                    ]),
            ]);
    }
}
