Deploy Ladill QR Plus / deploy (push) Successful in 40s
When a user hits an action they can't afford (e.g. creating a QR code with 0/low balance), open an in-app two-step modal instead of bouncing them to the central wallet page. Step 1 explains pay-as-you-go billing + shows the action cost and current balance; step 2 takes an amount and starts a Paystack checkout via the central identity wallet-topup API, returning the user where they were. - service-topup-modal: rebuilt as two-step (billing explainer -> amount/pay) - IdentityClient::walletTopup + WalletTopupController + POST /wallet/topup - balanceGate.openTopup / qrCustomizer.redirectTopup now prefer the modal, falling back to the wallet page only when no modal is wired - qr-codes index + create render the modal and open it on insufficient balance Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
100 lines
6.2 KiB
PHP
100 lines
6.2 KiB
PHP
<x-user-layout>
|
|
<x-slot name="title">QR Codes</x-slot>
|
|
|
|
<div class="space-y-6"
|
|
x-data="balanceGate({
|
|
balance: @js((float) $wallet->spendableBalance()),
|
|
price: @js((float) $pricePerQr),
|
|
topupUrl: @js($topupUrl),
|
|
modalId: 'qr',
|
|
href: @js(route('user.qr-codes.create')),
|
|
})">
|
|
@foreach(['success', 'error'] as $flash)
|
|
@if(session($flash))
|
|
<div class="rounded-lg border px-4 py-3 {{ $flash === 'success' ? 'border-emerald-200 bg-emerald-50 text-emerald-700' : 'border-red-200 bg-red-50 text-red-700' }}">
|
|
<p class="text-sm">{{ session($flash) }}</p>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
|
|
<div class="relative overflow-hidden rounded-2xl border border-slate-200 bg-white">
|
|
<div class="absolute inset-0 bg-gradient-to-br from-violet-50/80 via-white to-indigo-50/60"></div>
|
|
<div class="relative px-6 py-8 sm:px-10">
|
|
<div class="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
|
|
<div class="max-w-xl">
|
|
<div class="inline-flex items-center gap-1.5 rounded-full bg-violet-100 px-3 py-1 text-xs font-semibold text-violet-700">
|
|
GHS {{ number_format($pricePerQr, 2) }} per QR code
|
|
</div>
|
|
<h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">QR Codes</h1>
|
|
<p class="mt-2 text-sm leading-6 text-slate-600">
|
|
Create link and PDF QR codes with full scan analytics. Change destinations anytime without reprinting.
|
|
</p>
|
|
<div class="mt-6">
|
|
<button type="button"
|
|
@click="goOrTopup($event)"
|
|
class="btn-primary">
|
|
<svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg>
|
|
Create QR code
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="scrollbar-hide flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 sm:flex-wrap sm:justify-end sm:overflow-visible sm:pb-0 lg:gap-4" style="-ms-overflow-style:none;scrollbar-width:none;">
|
|
<div class="mobile-stats-card shrink-0 snap-start rounded-xl border border-slate-200 bg-white/90 px-4 py-3 text-center backdrop-blur-sm">
|
|
<p class="whitespace-nowrap text-xl font-bold text-slate-900 sm:text-2xl">GHS {{ number_format($wallet->spendableBalance(), 2) }}</p>
|
|
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">QR balance</p>
|
|
</div>
|
|
<div class="mobile-stats-card shrink-0 snap-start rounded-xl border border-slate-200 bg-white/90 px-4 py-3 text-center backdrop-blur-sm">
|
|
<p class="whitespace-nowrap text-xl font-bold text-slate-900 sm:text-2xl">{{ $qrCodes->count() }}</p>
|
|
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">QR codes</p>
|
|
</div>
|
|
<div class="mobile-stats-card shrink-0 snap-start rounded-xl border border-slate-200 bg-white/90 px-4 py-3 text-center backdrop-blur-sm">
|
|
<p class="whitespace-nowrap text-xl font-bold text-slate-900 sm:text-2xl">{{ number_format($wallet->scans_total) }}</p>
|
|
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">Total scans</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="rounded-2xl border border-slate-200 bg-white overflow-hidden">
|
|
<div class="border-b border-slate-100 px-6 py-4">
|
|
<h2 class="text-sm font-semibold text-slate-900">Your QR codes</h2>
|
|
</div>
|
|
@if($qrCodes->isEmpty())
|
|
<p class="px-6 py-10 text-center text-sm text-slate-500">No QR codes yet. Create your first QR code to get started.</p>
|
|
@else
|
|
<div class="divide-y divide-slate-100">
|
|
@foreach($qrCodes as $code)
|
|
<a href="{{ route('user.qr-codes.show', $code) }}" class="flex items-center gap-4 px-6 py-4 transition hover:bg-slate-50">
|
|
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg {{ $code->is_active ? 'bg-violet-100 text-violet-600' : 'bg-slate-100 text-slate-400' }}">
|
|
<x-icons.qr-code class="h-5 w-5" />
|
|
</div>
|
|
<div class="min-w-0 flex-1">
|
|
<p class="truncate text-sm font-semibold text-slate-900">{{ $code->label }}</p>
|
|
<p class="truncate text-xs text-slate-500">{{ $code->typeLabel() }} · {{ $code->publicUrl() }}</p>
|
|
</div>
|
|
<div class="text-right text-xs text-slate-500">
|
|
<p class="font-semibold text-slate-900">{{ number_format($code->scans_total) }} scans</p>
|
|
<p>{{ $code->is_active ? 'Active' : 'Paused' }}</p>
|
|
</div>
|
|
</a>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
{{-- Two-step add-funds modal (insufficient balance opens this instead of redirecting to the wallet) --}}
|
|
<x-user.service-topup-modal
|
|
id="qr"
|
|
title="Add funds"
|
|
:topup-action="route('user.wallet.topup')"
|
|
:price-per-action="(float) $pricePerQr"
|
|
action-noun="QR code"
|
|
:service-balance="(float) $wallet->spendableBalance()"
|
|
service-balance-label="Wallet balance"
|
|
:return-url="route('user.qr-codes.index')"
|
|
:open-on-load="session('open_topup_modal') === 'qr'" />
|
|
</div>
|
|
</x-user-layout>
|