@extends('layouts.app') @section('content') {{-- 1. FIXED BACKGROUND --}}
{{-- 2. MAIN CONTENT CONTAINER --}}
{{-- HEADER SECTION --}}

Loyalty & Rewards

Earn points with every booking and unlock exclusive rewards.

{{-- TOP STATS --}}

CURRENT TIER

{{ ucfirst($loyalty->tier ?? 'Bronze') }}

{{ number_format($loyalty->points ?? 0) }} PTS

{{-- MAIN GRID SYSTEM (2 COLUMNS) --}}
{{-- === LEFT COLUMN === --}}
{{-- 1. LOYALTY STATUS CARD (Fixed Height: h-[480px]) --}} {{-- Added: gold-glow-card class --}}
{{-- Header --}}

Loyalty Status

{{-- Stats Content (Distributed vertically) --}}
{{-- Points Earned --}}

Points Earned

{{ number_format($pointsEarned) }}

{{-- Points Redeemed --}}

Points Redeemed

{{ number_format($pointsRedeemed) }}

{{-- Total Points --}}

Total Points

{{ number_format($loyalty->points ?? 0) }}

{{-- 2. AVAILABLE REWARDS (Fixed Height: h-[550px]) --}} {{-- Added: gold-glow-card class --}}
{{-- Header --}}

Available Rewards

{{-- Grid Content (UPDATED WITH DB LOOP) --}}
@foreach($rewards as $reward) @if($reward->name == 'HASTAHD' || $reward->category == 'Milestone') @continue @endif
{{ $reward->points_required }} PTS

{{ $reward->name }}

{{ $reward->offer_description }}

@endforeach
{{-- === RIGHT COLUMN === --}}
{{-- LOYALTY ROAD CARD (FLIP INTERACTIVE) --}} {{-- Container Utama (Fixed Height) --}} {{-- Added: gold-glow-card to the wrapper --}}
{{-- INNER FLIPPER --}}
{{-- =============================================== --}} {{-- MUKA DEPAN (PROGRESS BAR) --}} {{-- =============================================== --}}
{{-- Header --}}

Loyalty Road

VALID FOR MORE THAN 9 HOURS BOOKINGS ONLY

Level {{ floor(($qualifiedBookingsCount ?? 0) / 12) + 1 }}
{{-- Progress Content Wrapper --}}
{{-- Stats Header --}}

Next Reward:

{{ $nextReward ?? '20% OFF' }}

{{ $currentInCycle ?? 0 }}/12
{{-- PROGRESS BAR (Alignment Fixed) --}}
{{-- Track --}}
{{-- Fill --}}
{{-- Dots & Labels --}} @foreach([3, 6, 9, 12] as $step) @php $pos = ($step / 12) * 100; $reached = ($currentInCycle ?? 0) >= $step; @endphp {{-- Dot --}}
{{-- Label --}}
{{ $step }}x
@endforeach
{{-- Instruction --}}

Book {{ $bookingsNeeded ?? 3 }} more times (>9hrs) to unlock {{ $nextReward }}!

{{-- Flip Hint --}}
Tap to View Reward List
{{-- Footer T&C --}}

Voucher T&C: Rewards can only be redeemed for bookings made on Monday - Thursday.

{{-- =============================================== --}} {{-- MUKA BELAKANG (REWARD LIST - MILESTONE ONLY) --}} {{-- =============================================== --}}
{{-- Header Belakang --}}

Milestone Rewards

Unlock by collecting stamps

{{-- LOGIC: KITA FILTER 'Milestone' SAHAJA --}} @php // 1. Ambil rewards dari variable $rewards // 2. Filter hanya Category = 'Milestone' (Abaikan Merchant/Point) // 3. Susun ikut step (3, 6, 9, 12) $milestoneRewards = isset($rewards) ? $rewards->where('category', 'Milestone')->sortBy('milestone_step') : collect([]); // Fallback jika DB kosong (Untuk demo sahaja) if($milestoneRewards->isEmpty()){ $milestoneRewards = collect([ (object)['milestone_step' => 3, 'name' => '20% OFF', 'offer_description' => '20% Discount for first 3 stamped bookings .'], (object)['milestone_step' => 6, 'name' => '50% OFF', 'offer_description' => '50% off for first 6 stamped bookings.'], (object)['milestone_step' => 9, 'name' => '70% OFF', 'offer_description' => '70% off for first 9 stamped bookings.'], (object)['milestone_step' => 12, 'name' => 'FREE HALF DAY', 'offer_description' => 'Free half-day rental (12 hours).'], ]); } @endphp @foreach($milestoneRewards as $reward) @php $isUnlocked = ($currentInCycle ?? 0) >= $reward->milestone_step; @endphp
{{-- Badge Stamp --}}
{{ $reward->milestone_step }}x
{{-- Text --}}

{{ $reward->name }}

{{ Str::limit($reward->offer_description, 45) }}

{{-- Icon Status --}}
@if($isUnlocked)
@else @endif
@endforeach

Tap card to flip back

{{-- 4. MY VOUCHERS (With History Tabs) --}} {{-- Added: gold-glow-card class --}}
{{-- Header with Tabs --}}

My Vouchers

{{-- Tabs Switcher --}}
{{ $vouchers->count() }} Available
{{-- CONTENT: ACTIVE VOUCHERS --}}
@forelse($vouchers as $voucher) {{-- Kad Voucher (Clickable untuk buka detail) --}}
{{-- IKON KIRI --}}
{{-- INFO TENGAH --}}
@if($voucher->voucherType == 'Merchant Reward')

{{ $voucher->redeem_place }}

@else {{-- [LOGIC BARU] Check dulu conditions dia --}} @if(str_contains(strtoupper($voucher->conditions ?? ''), 'FREE HALF DAY')) {{-- Kalau jumpa keyword FREE HALF DAY --}}

FREE HALF DAY

@else {{-- Kalau tak jumpa, baru tunjuk % --}}

{{ $voucher->discount_percent }}% OFF

@endif @endif {{-- KOD DIPAPARKAN TERUS DI SINI --}}
{{ $voucher->code }}
{{-- INFO KANAN (TARIKH) --}}

Expires

{{ \Carbon\Carbon::parse($voucher->validUntil)->format('d M') }}

@empty

No active vouchers.

@endforelse
{{-- CONTENT: HISTORY VOUCHERS (Hidden by Default) --}}
{{-- End Grid --}}
{{-- MODALS --}} {{-- [UPDATED] STYLISH VOUCHER DETAIL MODAL --}} {{-- SCRIPTS & STYLES --}} @endsection