@php use App\Enums\TrxType; use App\Enums\VirtualCard\VirtualCardStatus; @endphp @extends('frontend.layouts.user.index') @section('title', __('My Virtual Cards')) @push('styles') @endpush @section('content')
{{ __('Cardholders') }} {{ __('My Requests') }}
{{-- Stats strip --}}
{{ __('Total Balance') }}
{{ siteCurrency('symbol') . number_format($stats['total_balance'],siteDecimalPlaces()) }}
{{ __('across :n cards', ['n' => $stats['total_cards']]) }}
{{ __('Spent This Month') }}
{{ siteCurrency('symbol') . number_format($stats['monthly_spend'], siteDecimalPlaces()) }}
@if($stats['monthly_trend']) {{ $stats['monthly_trend']['pct'] }}% {{ __('vs last month') }} @else {{ __('No spend last month') }} @endif
{{ __('Pending Auth') }}
{{ siteCurrency('symbol') . number_format($stats['pending_auth'], siteDecimalPlaces()) }}
{{ __(':n transactions', ['n' => $stats['pending_count']]) }}
{{ __('Total Cards') }}
{{ $stats['total_cards'] }}
{{ __(':active active · :frozen frozen', ['active' => $stats['active_cards'], 'frozen' => $stats['frozen_cards']]) }}
@if($cards->count()) @php // Theme rotation per card so 3+ cards stay visually distinct $themeWheel = ['midnight', 'ocean', 'graphite', 'emerald', 'violet']; @endphp
{{-- LEFT: hero + switcher + transactions --}}
{{-- Card hero --}}
{{ __('Selected Card') }}

—

— —
{{-- Hero row: card visual + balance / monthly spend always side by side --}}
{{-- Active card visual injected by JS --}}
{{ __('Available Balance') }}
—
{{-- Value on top — its own line so the long "$X / $Y" string never gets squeezed against the label. --}}
—
{{-- Label below the bar — full-width so it can't be truncated. --}}
{{ __('Monthly spend') }}
{{-- Field boxes (Card Number + Expiry · CVV) sit below the hero so they get the full panel width and never compete for room with the balance/spend column. --}}
{{ __('Card Number') }}
•••• •••• •••• ••••
{{ __('Expiry · CVV') }}
— @if(!$demoMode) @else @endif
{{-- Quick actions: each is data-driven and capability-aware --}}
{{-- Card switcher --}}

{{ __('Your cards') }}

{{ __('Tap a card to inspect') }}
{{ __('View all') }}
@foreach($cards as $i => $card) @php // User-chosen theme wins; fall back to rotating wheel for legacy cards. $userTheme = $card->meta['theme'] ?? null; $theme = in_array($userTheme, $themeWheel, true) ? $userTheme : $themeWheel[$i % count($themeWheel)]; $providerCfg = $card->provider; $caps = $providerCfg ? $providerCfg->resolved_capabilities : config('virtual_card.default_capabilities'); $statusVal = $card->status?->value ?? 'active'; $isActive = $statusVal === VirtualCardStatus::Active->value; @endphp @php $providerCode = $providerCfg ? $providerCfg->code : null; $providerLabel = $providerCfg ? $providerCfg->dashboard_label : ''; $providerColor = $providerCfg ? $providerCfg->brand_color_hex : null; // Resolve a meaningful cardholder name + nickname: // — `cardholderName` → printed on the bottom-left of the card visual // — `cardholderLabel` → printed on the hero title row + on the card front "VIRTUAL · ..." $cardholderRow = optional($card->request)->cardholder; $cardholderName = $cardholderRow?->card_type?->isBusiness() && $cardholderRow?->business ? $cardholderRow->business->business_name : ($cardholderRow?->full_name ?: ($card->user->full_name ?? $card->user->name ?? __('Cardholder'))); $cardholderLabel = $card->wallet->name ?: ($card->wallet->currency->name ?: ($card->wallet->currency->code ?? __('Wallet'))); @endphp @endforeach
{{-- Recent transactions --}}

{{ __('Recent transactions') }}

{{ __('Top-ups and withdrawals across all cards') }}
{{ __('View all') }}
{{ __('Type') }}
{{ __('When') }}
{{ __('Status') }}
{{ __('Amount') }}
@forelse($recentTxns as $t) @php $isIn = $t->trx_type === TrxType::CARD_TOPUP; $statusObj = $t->status; @endphp
{{ $t->trx_type?->label() }} @if($t->provider) {{ Str::upper($t->provider) }} @endif
@if($t->trx_id) #{{ $t->trx_id }} @endif
{{ $t->created_at?->format('M d, H:i') }} {{ $t->created_at?->diffForHumans(null, true) }}
@if($statusObj) {{ $statusObj->label() }} @endif
{{ $isIn ? '+' : '−' }}{{ siteCurrency('symbol') . number_format((float) $t->amount,siteDecimalPlaces()) }}
@empty @endforelse
{{-- RIGHT: spending chart + provider mix + controls panel --}}
{{-- Spending bar chart --}}

{{ __('Spending') }}

{{ __('Daily · last 30 days') }}
— @if($stats['monthly_trend']) {{ $stats['monthly_trend']['pct'] }}% {{ __('vs last month') }} @endif
{{-- By provider donut --}}

{{ __('By provider') }}

{{ __('This month') }}
{{ __('Details') }}
@if(!empty($providerMix['items']))
{{ __('Spent') }}
{{ siteCurrency('symbol') . number_format($providerMix['total'], 0) }}
@foreach($providerMix['items'] as $item)
{{ $item['name'] }} {{ $item['pct'] }}% {{ siteCurrency('symbol') . number_format($item['value'], 0) }}
@endforeach
@else @endif
{{-- Card controls (soft toggles persisted to meta JSON) --}}

{{ __('Card controls') }}

{{ __('Applies to') }} —
{{ __('Saved') }}
{{ __('Online purchases') }}
{{ __('E-commerce, subscriptions') }}
{{ __('ATM withdrawals') }}
{{ __('Cash advances') }}
{{ __('International transactions') }}
{{ __('Outside merchant country') }}
{{ __('Contactless & in-store') }}
{{ __('NFC, mobile wallets') }}
@else @endif
{{-- Modals --}} @if(!$demoMode) @include('frontend.user.virtual_card.partials._card_details_modal') @endif @include('frontend.user.virtual_card.partials._topup_modal') @include('frontend.user.virtual_card.partials._withdraw_modal') @include('frontend.user.virtual_card.partials._freeze_modal') @include('frontend.user.virtual_card.partials._limits_modal') @include('frontend.user.virtual_card.request.partials._add_card_request_modal') @endsection @push('scripts') @include('frontend.user.virtual_card.partials._script') @endpush