/* global React */ const { useState, useEffect } = React; const BRIDGE_URL = 'https://ipbridge.indiegroup.id'; const STATUS_LABEL = { pending_payment: { label: 'Menunggu pembayaran', color: '#D97706' }, paid: { label: 'Dibayar', color: '#059669' }, processing: { label: 'Diproses', color: '#2563EB' }, shipped: { label: 'Dikirim', color: '#7C3AED' }, delivered: { label: 'Terkirim', color: '#059669' }, cancelled: { label: 'Dibatalkan', color: '#DC2626' }, }; function OrdersPage({ navigate }) { const [orders, setOrders] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!window.IndieAuth.isLoggedIn()) { navigate('/gallery'); return; } const profile = window.IndieAuth.getProfile(); if (!profile?.email) { setLoading(false); return; } fetch(BRIDGE_URL + '/orders?email=' + encodeURIComponent(profile.email)) .then(r => r.json()) .then(d => { if (d.ok) setOrders(d.orders || []); else setError(d.error); setLoading(false); }) .catch(e => { setError(e.message); setLoading(false); }); }, []); return (

Riwayat Order

{loading &&
Memuat orders…
} {error &&
{error}
} {!loading && orders.length === 0 && (

Belum ada order.

)} {orders.map(order => { const st = STATUS_LABEL[order.status] || { label: order.status, color: '#6B7280' }; return (
{order.order_number} {new Date(order.created_at).toLocaleDateString('id-ID',{day:'numeric',month:'long',year:'numeric'})}
{st.label}
{order.shipping_address?.city && 📍 {order.shipping_address.city}}
Rp {(order.total||0).toLocaleString('id-ID')}
{order.xendit_invoice_url && order.status === 'pending_payment' && (
Lanjut pembayaran →
)}
); })}
); } window.OrdersPage = OrdersPage;