<?php

namespace App\Filament\Resources\PaymentTransactions\Schemas;

use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Schema;

class PaymentTransactionInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                TextEntry::make('user.email')
                    ->label('User')
                    ->placeholder('-'),
                TextEntry::make('plan.name')
                    ->label('Plan')
                    ->placeholder('-'),
                TextEntry::make('gateway'),
                TextEntry::make('type'),
                TextEntry::make('status')
                    ->badge(),
                TextEntry::make('amount')
                    ->money(fn ($record): string => strtoupper($record->currency ?: 'usd')),
                TextEntry::make('fee')
                    ->money(fn ($record): string => strtoupper($record->currency ?: 'usd')),
                TextEntry::make('net_amount')
                    ->money(fn ($record): string => strtoupper($record->currency ?: 'usd')),
                TextEntry::make('transaction_id')
                    ->placeholder('-'),
                TextEntry::make('payment_intent_id')
                    ->placeholder('-'),
                TextEntry::make('customer_ref')
                    ->placeholder('-'),
                TextEntry::make('subscription_ref')
                    ->placeholder('-'),
                TextEntry::make('invoice_ref')
                    ->placeholder('-'),
                TextEntry::make('billing_email')
                    ->placeholder('-'),
                TextEntry::make('paid_at')
                    ->dateTime()
                    ->placeholder('-'),
                TextEntry::make('metadata')
                    ->formatStateUsing(fn ($state): string => $state ? json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) : '-')
                    ->columnSpanFull(),
                TextEntry::make('created_at')
                    ->dateTime()
                    ->placeholder('-'),
                TextEntry::make('updated_at')
                    ->dateTime()
                    ->placeholder('-'),
            ]);
    }
}
