@extends('layouts.public') @section('content') @php /** @var array $user @var array $wallets */ $wallets = $wallets ?? []; @endphp

{{ t_raw('account.loyalty') }}

@php /* The page's messages belong UNDER its title band, inside the page the reader is looking at — not floating above it. getFlashes() consumes, so the layout's own call further out finds nothing and does not draw it twice. */ @endphp
@partial('flash')
@partial('account-nav')
@php /* Points are keyed to a phone number: an account without one earns nothing, and this is where the customer learns that, with the one-click way to fix it. */ @endphp @if (trim((string) ($user['phone'] ?? '')) === '') @endif @if (empty($wallets))

{{ t_raw('vendor.loyalty.empty_no_rewards_title') }}

{{ t_raw('account.no_rewards_empty_text') }}

{{ t_raw('restaurant.browse') }}
@else @foreach ($wallets as $w) @php $acct = $w['account']; $balance = (int) $w['balance']; $label = (string) $w['label']; $slug = (string) ($acct['restaurant_slug'] ?? ''); $cheapest = $w['cheapest']; $pct = (int) $w['progress_pct']; $toGo = (int) $w['to_go']; @endphp
@if ($cheapest)

@if ($toGo <= 0) {!! t_raw('account.redeem_now_text', [':title' => '' . e((string) $cheapest['title']) . '']) !!} @else {!! t_raw('account.more_to_unlock_text', [':n' => '' . number_format($toGo) . '', ':label' => e($label), ':title' => '' . e((string) $cheapest['title']) . '']) !!} @endif

@endif @if (!empty($w['rewards']))
@foreach ($w['rewards'] as $rw) @php $cost = (int) $rw['points_cost']; $eligible = $balance >= $cost; $isFree = ($rw['type'] ?? '') === 'free_item'; @endphp

{{ (string) $rw['title'] }}

{{ loyalty_points($cost, $label) }} @if ($eligible) {{ t_raw('account.claim_at_checkout') }} @else {{ t_raw('account.need_more_text', [':n' => number_format($cost - $balance), ':label' => $label]) }} @endif
@endforeach
@endif @if (!empty($w['ledger']))

{{ t_raw('vendor.staff.heading_recent_activity') }}

    @foreach ($w['ledger'] as $tx) @php $pts = (int) $tx['points']; $up = $pts >= 0; $note = (string) ($tx['note'] ?? ''); $type = (string) ($tx['type'] ?? ''); if ($note === '') { $note = status_label('loyalty_tx', $type); }; @endphp
  • {{ $note }} {{ $up ? '+' : '−' }}{{ number_format(abs($pts)) }} {!! fmt_day($tx['created_at']) !!}
  • @endforeach
@endif
@endforeach @endif
@endsection