Add Events-style heroes to Storefronts and Products index pages.
Deploy Ladill Merchant / deploy (push) Successful in 42s

Surface wallet balance and key counts in gradient hero sections so Merchant list pages match the Events pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-04 16:55:16 +00:00
co-authored by Cursor
parent 742592ab0d
commit 30ec8943dc
4 changed files with 204 additions and 95 deletions
+104 -65
View File
@@ -1,75 +1,114 @@
<x-user-layout>
<x-slot name="title">Products</x-slot>
<div class="space-y-6">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 class="text-xl font-semibold text-slate-900">Products</h1>
<p class="mt-1 text-sm text-slate-500">Your product catalog, synced with Ladill CRM. Use these on any storefront.</p>
@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">
Catalog · Pricing · Inventory-ready
</div>
<h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">Your products</h1>
<p class="mt-2 text-sm leading-6 text-slate-600">
Manage your product catalog in Ladill CRM and use items across any storefront.
</p>
<div class="mt-6">
<a href="{{ route('merchant.products.create') }}" 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 product
</a>
</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">{{ number_format($productCount) }}</p>
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">Products</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>
<x-btn.create :href="route('merchant.products.create')">New product</x-btn.create>
</div>
@if(session('success'))
<div class="rounded-xl border border-emerald-100 bg-emerald-50 px-4 py-3 text-sm text-emerald-700">{{ session('success') }}</div>
@endif
<form method="get" class="flex max-w-sm items-center gap-2">
<input type="search" name="search" value="{{ $search }}" placeholder="Search products…"
class="w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500">
<button class="rounded-xl border border-slate-200 px-3 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50">Search</button>
</form>
@if(empty($products))
<div class="rounded-2xl border border-dashed border-slate-200 bg-white px-6 py-12 text-center">
<p class="text-sm text-slate-500">{{ $search !== '' ? 'No products match your search.' : 'No products yet.' }}</p>
<a href="{{ route('merchant.products.create') }}" class="mt-3 inline-block text-sm font-semibold text-indigo-600 hover:text-indigo-800">Add your first product</a>
<div class="rounded-2xl border border-slate-200 bg-white overflow-hidden">
<div class="flex flex-col gap-3 border-b border-slate-100 px-6 py-4 sm:flex-row sm:items-center sm:justify-between">
<h2 class="text-sm font-semibold text-slate-900">Your products</h2>
<form method="get" class="flex w-full max-w-sm items-center gap-2 sm:w-auto">
<input type="search" name="search" value="{{ $search }}" placeholder="Search products…"
class="w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500">
<button class="shrink-0 rounded-xl border border-slate-200 px-3 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50">Search</button>
</form>
</div>
@else
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full divide-y divide-slate-100 text-sm">
<thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">
<tr>
<th class="px-4 py-3">Product</th>
<th class="px-4 py-3">SKU</th>
<th class="px-4 py-3 text-right">Price</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@foreach($products as $p)
<tr class="hover:bg-slate-50/60">
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $p['name'] ?? '—' }}</p>
@if(!empty($p['description']))
<p class="mt-0.5 truncate text-xs text-slate-400">{{ \Illuminate\Support\Str::limit($p['description'], 60) }}</p>
@endif
</td>
<td class="px-4 py-3 text-slate-500">{{ $p['sku'] ?: '—' }}</td>
<td class="px-4 py-3 text-right font-medium text-slate-900">
{{ strtoupper($p['currency'] ?? 'GHS') }} {{ number_format(((int) ($p['unit_price_minor'] ?? 0)) / 100, 2) }}
</td>
<td class="px-4 py-3">
<span class="inline-flex rounded-full px-2 py-0.5 text-xs font-medium {{ ($p['active'] ?? true) ? 'bg-emerald-50 text-emerald-700' : 'bg-slate-100 text-slate-500' }}">
{{ ($p['active'] ?? true) ? 'Active' : 'Inactive' }}
</span>
</td>
<td class="px-4 py-3 text-right">
<div class="flex items-center justify-end gap-3">
<a href="{{ route('merchant.products.edit', $p['id']) }}" class="text-sm font-medium text-indigo-600 hover:text-indigo-800">Edit</a>
<form method="post" action="{{ route('merchant.products.destroy', $p['id']) }}"
onsubmit="return confirm('Delete this product?');">
@csrf
@method('DELETE')
<button class="text-sm font-medium text-red-500 hover:text-red-700">Delete</button>
</form>
</div>
</td>
@if(empty($products))
<p class="px-6 py-10 text-center text-sm text-slate-500">
{{ $search !== '' ? 'No products match your search.' : 'No products yet. Add your first product to get started.' }}
</p>
@else
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-100 text-sm">
<thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">
<tr>
<th class="px-4 py-3">Product</th>
<th class="px-4 py-3">SKU</th>
<th class="px-4 py-3 text-right">Price</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3"></th>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</thead>
<tbody class="divide-y divide-slate-100">
@foreach($products as $p)
<tr class="hover:bg-slate-50/60">
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $p['name'] ?? '—' }}</p>
@if(!empty($p['description']))
<p class="mt-0.5 truncate text-xs text-slate-400">{{ \Illuminate\Support\Str::limit($p['description'], 60) }}</p>
@endif
</td>
<td class="px-4 py-3 text-slate-500">{{ $p['sku'] ?: '—' }}</td>
<td class="px-4 py-3 text-right font-medium text-slate-900">
{{ strtoupper($p['currency'] ?? 'GHS') }} {{ number_format(((int) ($p['unit_price_minor'] ?? 0)) / 100, 2) }}
</td>
<td class="px-4 py-3">
<span class="inline-flex rounded-full px-2 py-0.5 text-xs font-medium {{ ($p['active'] ?? true) ? 'bg-emerald-50 text-emerald-700' : 'bg-slate-100 text-slate-500' }}">
{{ ($p['active'] ?? true) ? 'Active' : 'Inactive' }}
</span>
</td>
<td class="px-4 py-3 text-right">
<div class="flex items-center justify-end gap-3">
<a href="{{ route('merchant.products.edit', $p['id']) }}" class="text-sm font-medium text-indigo-600 hover:text-indigo-800">Edit</a>
<form method="post" action="{{ route('merchant.products.destroy', $p['id']) }}"
onsubmit="return confirm('Delete this product?');">
@csrf
@method('DELETE')
<button class="text-sm font-medium text-red-500 hover:text-red-700">Delete</button>
</form>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
</x-user-layout>
@@ -1,35 +1,89 @@
<x-user-layout>
<x-slot name="title">Storefronts</x-slot>
<div class="space-y-6">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 class="text-xl font-semibold text-slate-900">Storefronts</h1>
<p class="mt-1 text-sm text-slate-500">Shop, menu & booking QR storefronts with online checkout.</p>
</div>
<x-btn.create :href="route('merchant.storefronts.create', ['type' => 'shop'])">New storefront</x-btn.create>
</div>
@if($qrCodes->isEmpty())
<div class="rounded-2xl border border-dashed border-slate-200 bg-white px-6 py-12 text-center">
<p class="text-sm text-slate-500">No storefronts yet.</p>
<a href="{{ route('merchant.storefronts.create', ['type' => 'shop']) }}" class="mt-3 inline-block text-sm font-semibold text-indigo-600 hover:text-indigo-800">Create your first storefront</a>
</div>
@else
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
@foreach($qrCodes as $qr)
<a href="{{ route('merchant.storefronts.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 rounded-lg border border-slate-100 bg-white p-1">
@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 class="space-y-6"
x-data="balanceGate({
balance: @js((float) $wallet->spendableBalance()),
price: @js((float) $pricePerQr),
topupUrl: @js($topupUrl),
href: @js(route('merchant.storefronts.create', ['type' => 'shop'])),
})">
@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">
Shop · Menu · Booking · Online checkout
</div>
</a>
@endforeach
<h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">Your storefronts</h1>
<p class="mt-2 text-sm leading-6 text-slate-600">
Create QR storefronts for shops, menus, and bookings. Share a Ladill Link and take orders online.
</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 storefront
</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">Storefronts</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>
@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 storefronts</h2>
</div>
@if($qrCodes->isEmpty())
<p class="px-6 py-10 text-center text-sm text-slate-500">No storefronts yet. Create your first storefront 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('merchant.storefronts.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 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' }}">
<img src="{{ asset('images/ladill-icons/storefront.svg') }}?v={{ @filemtime(public_path('images/ladill-icons/storefront.svg')) ?: '1' }}" alt="" class="h-8 w-8 object-contain" width="32" height="32">
</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>
</x-user-layout>