import Link from 'next/link' import { ArrowRight, CircleCheck, Package } from 'lucide-react' export const dynamic = 'force-dynamic' const VULA_URL = process.env.VULA_CMS_URL || 'https://ide.vulai.co.za' const PROJECT_ID = process.env.VULA_CMS_PROJECT_ID || '' const CURRENCY_SYMBOLS: Record = { zar: 'R', usd: '$', eur: '€', gbp: '£', kes: 'KSh', ngn: '₦', ghs: '₵' } const formatPrice = (amount: number, code?: string) => { const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '') return `${sym}${(amount / 100).toFixed(2)}` } async function getOrder(orderId: string) { if (!PROJECT_ID) return null try { const res = await fetch(`${VULA_URL}/api/store/${PROJECT_ID}/orders/${orderId}`, { cache: 'no-store', signal: AbortSignal.timeout(8000), }) if (!res.ok) return null const data = await res.json() return data.order ?? null } catch { return null } } interface PageProps { params: { orderId: string } } export default async function OrderConfirmationPage({ params }: PageProps) { const order = await getOrder(params.orderId) const currencyCode = 'zar' const items: Array<{ title?: string; variant_title?: string; unit_price: number; quantity: number; thumbnail?: string | null }> = order?.items ?? [] return (

Order Confirmed!

{order?.email ? `A confirmation has been sent to ${order.email}.` : 'Thank you for your order.'}

Order Details

{order && ( #{order.display_id ?? params.orderId.slice(0, 8).toUpperCase()} )}
{items.length > 0 ? (
    {items.map((item, i) => (
  • {item.thumbnail && ( {item.title )}

    {item.title ?? 'Product'}

    {item.variant_title && item.variant_title !== 'Default Title' && (

    {item.variant_title}

    )}

    Qty: {item.quantity}

    {formatPrice((item.unit_price ?? 0) * item.quantity, currencyCode)}

  • ))}
) : (

Your items are being prepared.

)} {order?.total != null && (
Total {formatPrice(order.total, currencyCode)}
)}
{order?.shipping_address && (

Delivering to

{order.customer &&

{order.customer.first_name} {order.customer.last_name}

}

{order.shipping_address.address_1}

{order.shipping_address.city}, {order.shipping_address.postal_code}

)}
Continue Shopping Back to Home
) }