Add Merchant-style hero to Giving Pages index.
Deploy Ladill Give / deploy (push) Successful in 1m5s

Surface wallet balance, page count, and active stats in a gradient hero with balance-gated create CTA.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-04 20:39:40 +00:00
co-authored by Cursor
parent e5e380bee9
commit 4145c5f7d5
2 changed files with 92 additions and 29 deletions
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Give;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\QrCode; use App\Models\QrCode;
use App\Models\QrWallet;
use App\Services\Qr\QrCodeManagerService; use App\Services\Qr\QrCodeManagerService;
use App\Services\Qr\QrImageGeneratorService; use App\Services\Qr\QrImageGeneratorService;
use App\Services\Qr\QrPdfExporter; use App\Services\Qr\QrPdfExporter;
@@ -36,9 +37,15 @@ class GivingPageController extends Controller
return [$qr->id => $this->imageGenerator->previewDataUri($qr)]; return [$qr->id => $this->imageGenerator->previewDataUri($qr)];
}); });
$wallet = $this->manager->walletFor($account);
return view('give.giving-pages.index', [ return view('give.giving-pages.index', [
'qrCodes' => $qrCodes, 'qrCodes' => $qrCodes,
'previewDataUris' => $previewDataUris, 'previewDataUris' => $previewDataUris,
'wallet' => $wallet,
'activeCount' => $qrCodes->where('is_active', true)->count(),
'pricePerQr' => QrWallet::pricePerQr(),
'topupUrl' => 'https://'.config('app.account_domain').'/wallet',
]); ]);
} }
@@ -1,35 +1,91 @@
<x-user-layout> <x-user-layout>
<x-slot name="title">Giving Pages</x-slot> <x-slot name="title">Giving Pages</x-slot>
<div class="space-y-6">
<div class="flex flex-wrap items-center justify-between gap-3"> <div class="space-y-6"
<div> x-data="balanceGate({
<h1 class="text-xl font-semibold text-slate-900">Giving pages</h1> balance: @js((float) $wallet->spendableBalance()),
<p class="mt-1 text-sm text-slate-500">Branded pages with a printable QR for online giving.</p> price: @js((float) $pricePerQr),
</div> topupUrl: @js($topupUrl),
<x-btn.create :href="route('give.giving-pages.create')">New giving page</x-btn.create> href: @js(route('give.giving-pages.create')),
</div> })">
@if($qrCodes->isEmpty()) @foreach(['success', 'error'] as $flash)
<div class="rounded-2xl border border-dashed border-slate-200 bg-white px-6 py-12 text-center"> @if(session($flash))
<p class="text-sm text-slate-500">No giving pages yet.</p> <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' }}">
<a href="{{ route('give.giving-pages.create') }}" class="mt-3 inline-block text-sm font-semibold text-indigo-600 hover:text-indigo-800">Create your first giving page</a> <p class="text-sm">{{ session($flash) }}</p>
</div> </div>
@else @endif
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3"> @endforeach
@foreach($qrCodes as $qr)
<a href="{{ route('give.giving-pages.show', $qr) }}" class="rounded-2xl border border-slate-200 bg-white p-5 transition hover:border-indigo-200 hover:shadow-sm"> <div class="relative overflow-hidden rounded-2xl border border-slate-200 bg-white">
<div class="flex items-start gap-4"> <div class="absolute inset-0 bg-gradient-to-br from-violet-50/80 via-white to-indigo-50/60"></div>
@if(!empty($previewDataUris[$qr->id])) <div class="relative px-6 py-8 sm:px-10">
<img src="{{ $previewDataUris[$qr->id] }}" alt="" class="h-16 w-16 rounded-lg border border-slate-100 bg-white p-1"> <div class="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
@endif <div class="max-w-xl">
<div class="min-w-0 flex-1"> <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">
<p class="truncate font-semibold text-slate-900">{{ $qr->label }}</p> Tithes · Offerings · Campaigns
<p class="mt-0.5 truncate text-sm text-slate-500">{{ $qr->content()['name'] ?? 'Organisation' }}</p>
<p class="mt-2 truncate text-xs text-slate-400">{{ $qr->is_active ? 'Active' : 'Inactive' }} · {{ $qr->publicUrl() }}</p>
</div>
</div> </div>
</a> <h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">Your giving pages</h1>
@endforeach <p class="mt-2 text-sm leading-6 text-slate-600">
Branded donation pages with a printable QR. Share a Ladill Link so supporters can give online in seconds.
</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>
New giving page
</button>
</div>
</div>
<div class="scrollbar-hide flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 sm:grid sm:grid-cols-3 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">Account 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">Giving pages</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($activeCount) }}</p>
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">Active</p>
</div>
</div>
</div>
</div> </div>
@endif </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 giving pages</h2>
</div>
@if($qrCodes->isEmpty())
<p class="px-6 py-10 text-center text-sm text-slate-500">No giving pages yet. Create your first giving page to get started.</p>
@else
<div class="grid gap-4 p-6 sm:grid-cols-2 xl:grid-cols-3">
@foreach($qrCodes as $qr)
<a href="{{ route('give.giving-pages.show', $qr) }}" class="rounded-2xl border border-slate-200 bg-white p-5 transition hover:border-indigo-200 hover:shadow-sm">
<div class="flex items-start gap-4">
@if(!empty($previewDataUris[$qr->id]))
<img src="{{ $previewDataUris[$qr->id] }}" alt="" class="h-16 w-16 shrink-0 rounded-lg border border-slate-100 bg-white p-1">
@else
<div class="flex h-16 w-16 shrink-0 items-center justify-center rounded-lg {{ $qr->is_active ? 'bg-violet-100' : 'bg-slate-100 opacity-50' }}">
<svg class="h-8 w-8 text-violet-600" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z" />
</svg>
</div>
@endif
<div class="min-w-0 flex-1">
<p class="truncate font-semibold text-slate-900">{{ $qr->label }}</p>
<p class="mt-0.5 truncate text-sm text-slate-500">{{ $qr->content()['name'] ?? 'Organisation' }}</p>
<p class="mt-2 truncate text-xs text-slate-400">{{ $qr->is_active ? 'Active' : 'Inactive' }} · {{ $qr->publicUrl() }}</p>
</div>
</div>
</a>
@endforeach
</div>
@endif
</div>
</div> </div>
</x-user-layout> </x-user-layout>