@include('partials.navbar')
{{-- ── Header ── --}}

Riwayat

Pesanan Saya

{{-- ── Tabs ── --}}
{{-- ── Order list ── --}}
@forelse($orders as $index => $order) @php $isPending = $order->status === 'pending'; $statusLabel = 'Menunggu Konfirmasi'; $statusBg = 'bg-yellow-50 text-yellow-700 border-yellow-200/60'; $statusIcon = 'fas fa-hourglass-half'; if ($order->status === 'pending') { $statusLabel = 'Belum Dibayar'; $statusBg = 'bg-[#fff5f5] text-[#8B0000] border-[#8B0000]/10'; $statusIcon = 'fas fa-clock'; } elseif (in_array($order->status, ['confirmed', 'shipped'])) { $statusLabel = 'Sedang Diproses'; $statusBg = 'bg-blue-50 text-blue-600 border-blue-200/60'; $statusIcon = 'fas fa-fire'; } elseif ($order->status === 'completed') { $statusLabel = 'Selesai'; $statusBg = 'bg-emerald-50 text-emerald-600 border-emerald-200/60'; $statusIcon = 'fas fa-check-circle'; } elseif ($order->status === 'rejected') { $statusLabel = 'Dibatalkan'; $statusBg = 'bg-gray-50 text-gray-500 border-gray-200/60'; $statusIcon = 'fas fa-times-circle'; } $items = is_array($order->items) ? $order->items : json_decode($order->items, true); $firstItem = !empty($items) ? $items[0] : null; $itemCount = is_array($items) ? count($items) : 0; $reviewedOrderIds = $reviewedOrderIds ?? []; $isReviewed = in_array($order->order_id, $reviewedOrderIds, true); @endphp
{{-- Card header --}}
{{ $statusLabel }}
{{ optional($order->created_at)->format('d M Y, H:i') }}
{{-- Card body --}}
@if($order->status === 'completed') {{-- All items for completed --}}
@foreach($items as $iIt => $it)
@if(isset($it['image']) && $it['image']) {{ $it['name'] ?? '' }} @else
@endif

{{ $it['name'] ?? 'Pesanan Custom' }}

{{ (int)($it['quantity'] ?? 1) }}x · Rp {{ number_format((float)($it['price'] ?? 0), 0, ',', '.') }}

@if(!$loop->last)
@endif @endforeach
@else {{-- First item only --}}
@if($firstItem && isset($firstItem['image'])) {{ $firstItem['name'] }} @else
@endif
@if($firstItem)

{{ $firstItem['name'] }}

{{ (int)($firstItem['quantity'] ?? 1) }}x · Rp {{ number_format((float)($firstItem['price'] ?? 0), 0, ',', '.') }}

@else

Pesanan Custom

@endif @if($itemCount > 1)

+ {{ $itemCount - 1 }} produk lainnya

@endif
@endif
{{-- Card footer --}}
{{-- Left: ID + total --}}

{{ $order->order_id }}

Rp {{ number_format((float) $order->total_price, 0, ',', '.') }}

{{-- Right: actions --}}
@if($order->status === 'completed' && !$isReviewed) Tulis Ulasan @elseif($order->status === 'completed' && $isReviewed) Sudah Diulas Pesan Lagi @else Detail @endif
{{-- Mobile quick rating --}} @if($order->status === 'completed' && !$isReviewed)
Ulasan Cepat
@for($i=1; $i<=5; $i++) @endfor
@endif
@empty {{-- Empty state --}}

Belum ada pesanan

Anda belum pernah melakukan pemesanan untuk status ini. Yuk, mulai pesan sekarang!

Belanja Sekarang
@endforelse