@extends('frontend.layouts.user.index') @section('title', __('Create Gift Card')) @push('styles') @endpush @section('content') @php /* * Build serialisable payloads for the JS layer. Templates and wallets * are also rendered server-side below — these arrays exist so the * client-side preview/summary logic can resolve a selected template's * preset_key or a wallet's currency symbol without hitting the DOM * for every read. */ $templatesPayload = $templates->map(fn ($t) => [ 'id' => $t->id, 'name' => $t->name, 'category' => $t->category, 'preset_key' => $t->preset_key ?: 'premium', 'default_amount' => $t->default_amount !== null ? (float) $t->default_amount : null, ])->values(); /* * Per-wallet fee + limit payload. Each wallet carries the currency * role row already (eager-loaded in the controller) — we pull the * gift_card role first, falling back to the voucher role for * wallets that haven't been configured with a dedicated gift_card * role yet (matches the controller's own resolveRole() logic). * * The frontend uses these to render an *accurate* order summary * instead of the previous hardcoded 1.5% placeholder. Backend * still recalculates at submit (single source of truth) — the * payload is for live preview only. */ $walletsPayload = $wallets->map(function ($w) { $role = $w->currency?->roles?->firstWhere('role_name', \App\Constants\CurrencyRole::GIFT_CARD) ?? $w->currency?->roles?->firstWhere('role_name', \App\Constants\CurrencyRole::VOUCHER); return [ 'id' => $w->id, 'name' => $w->name, 'balance' => (float) $w->balance, 'currency' => $w->currency->code ?? 'USD', 'symbol' => $w->currency->symbol ?? '$', 'fee' => (float) ($role->fee ?? 0), 'fee_type' => $role->fee_type ?? 'percent', 'min_limit' => $role->min_limit !== null ? (float) $role->min_limit : null, 'max_limit' => $role->max_limit !== null ? (float) $role->max_limit : null, 'role_name' => $role->role_name ?? null, ]; })->values(); $defaultSender = auth()->user()?->name ?? ''; @endphp
{{-- Page header — uses the project's shared component so the look matches voucher / payment-links / send-money and every other user-facing feature page in the app. --}} {{-- Stepper --}}
@foreach([__('Design'), __('Amount'), __('Recipient'), __('Review')] as $idx => $label) @php $n = $idx + 1; @endphp @if($n < 4)
@endif @endforeach
@if($wallets->isEmpty())
@else
@csrf {{-- Hidden inputs the form actually submits — kept in sync by JS. --}}
{{-- ─── STEP 1: Templates ────────────────────────── --}}

{{ __('Choose a design') }}

{{ __('The look the recipient sees when they open the card.') }}

{{ $templates->count() }} {{ __('designs') }}
@foreach($categories as $cat) @endforeach
@foreach($templates as $i => $t) @endforeach
{{-- ─── STEP 2: Amount & wallet ──────────────────── --}}

{{ __('Amount & wallet') }}

{{ __('Funds are reserved from your wallet when you create the gift card.') }}

@foreach($wallets as $i => $w) @endforeach
$ USD
{{ __('Funds reserved from') }} —
@foreach([25, 50, 100, 200] as $v) @endforeach
{{-- ─── STEP 3: Recipient ────────────────────────── --}}

{{ __('Who is it for?') }}

{{ __('We will deliver the card by email, with a private redeem link.') }}

{{-- ─── STEP 4: Review ───────────────────────────── --}}

{{ __('Review & send') }}

{{ __('Confirm everything below — once sent, the recipient gets an email immediately.') }}

{{ __('Design') }}
—
—
{{ __('Amount') }}
—
{{ __('From') }} —
{{ __('Recipient') }}
—
—
{{ __('Delivery') }}
{{ __('Send immediately') }}
{{ __('By email') }}
{{ __('Personal message') }}
{{ __('No message added.') }}
{{ __('Cards expire after 12 months') }}
{{ __('Unredeemed funds return to your wallet.') }}
{{-- Footer navigation --}}
{{ __('Step') }} 1 / 4
{{-- ─── Sidebar: Live preview + Order summary ──────────── --}}
{{ __('Live preview') }}
{{ __('Order summary') }}
  • {{ __('Gift card value') }} —
  • {{ __('Service fee') }} —
  • {{ __('Delivery') }} {{ __('Email') }}
  • {{ __('Payable from') }} — —
{{ __('Secure transaction via :site', ['site' => setting('site_title', config('app.name'))]) }}
@endif
@endsection @push('scripts') @endpush