From 183b5d739fa9aa3b726f19eb984a049376e964b7 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Fri, 31 Jul 2026 14:12:37 +0000 Subject: [PATCH] Deploy --- src/app/order/[orderId]/page.tsx | 115 +++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/app/order/[orderId]/page.tsx diff --git a/src/app/order/[orderId]/page.tsx b/src/app/order/[orderId]/page.tsx new file mode 100644 index 0000000..0a7a94c --- /dev/null +++ b/src/app/order/[orderId]/page.tsx @@ -0,0 +1,115 @@ +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 + +
+
+
+ ) +}