{{-- Membership offer for the merchant (dashboard): the main admin created it in Kelola Pengguna, and the merchant joins it here. Joining (membership.join) makes a QRIS order for the price; the dashboard's QRIS popup pays it and completing it starts 30 days. Shown while the merchant has an offer but no running membership (new or expired). Needs $memberQuota (the /api/auth/me membership) and $paketData (GET /api/packages, for a pending membership order). --}} @php $offer = is_array($memberQuota ?? null) && ! data_get($memberQuota, 'active', false) ? $memberQuota : null; $offerRows = []; if ($offer) { foreach (['sms' => 'SMS', 'mms' => 'MMS', 'waba' => 'WA Business'] as $offerChannel => $offerChannelLabel) { foreach (['broadcast' => 'Broadcast', 'targeted' => 'Targeted', 'lba' => 'LBA'] as $offerKind => $offerKindLabel) { // null limit = unlimited; 0 = the service is not part of the membership. $offerLimit = data_get($offer, $offerChannel.'_'.$offerKind.'_limit', 0); if ($offerLimit === null || (int) $offerLimit > 0) { $offerRows[] = ['label' => $offerChannelLabel.' '.$offerKindLabel, 'limit' => $offerLimit === null ? null : (int) $offerLimit]; } } } } // Headline: an unlimited service first, otherwise the biggest quota. usort($offerRows, fn (array $a, array $b): int => ($b['limit'] ?? PHP_INT_MAX) <=> ($a['limit'] ?? PHP_INT_MAX)); $offerTop = $offerRows[0] ?? null; $offerPrice = (int) data_get($offer, 'price', 0); $offerPriceLabel = 'Rp '.number_format($offerPrice, 0, ',', '.'); // A QRIS order for the offer that is not paid yet: its popup is opened instead of a new join. $offerOrder = collect(data_get($paketData ?? [], 'orders', [])) ->first(fn ($order) => is_array($order) && ($order['kind'] ?? '') === 'membership' && ! empty($order['id'])); $offerError = $errors->first('membership_join'); $offerWasMember = $offer && data_get($offer, 'expires_at'); @endphp @if (session('membership_joined'))
{{ session('membership_joined') }}
@endif @if ($offer)@if ($offerTop) Blast {{ $offerTop['label'] }} {{ $offerTop['limit'] === null ? 'tanpa batas' : number_format($offerTop['limit'], 0, ',', '.').' pesan' }}@if (count($offerRows) > 1) + {{ count($offerRows) - 1 }} layanan lainnya @endif — @endif hanya {{ $offerPriceLabel }}/bln