From 4e89b4bc52f5017c307b5a64902da77796bbc5df Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 23 Jun 2026 08:47:48 +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..70b2441 --- /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 BACKEND_URL = process.env.VULA_ECOMMERCE_BACKEND_URL || 'http://vula-ecommerce:9000' +const PUB_KEY = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY || '' +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) { + try { + const res = await fetch(`${BACKEND_URL}/store/orders/${orderId}`, { + headers: { 'x-publishable-api-key': PUB_KEY }, + cache: 'no-store', + signal: AbortSignal.timeout(8000), + }) + if (!res.ok) return null + const { order } = await res.json() + return order + } catch { + return null + } +} + +interface PageProps { params: { orderId: string } } + +export default async function OrderConfirmationPage({ params }: PageProps) { + const order = await getOrder(params.orderId) + const currencyCode = order?.currency_code + const items = 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: any) => ( +
  • + {item.thumbnail && ( + {item.product_title + )} +
    +

    {item.product_title || item.title}

    + {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 && ( +
+ Total + {formatPrice(order.total, currencyCode)} +
+ )} +
+ + {order?.shipping_address && ( +
+

Delivering to

+
+

{order.shipping_address.first_name} {order.shipping_address.last_name}

+

{order.shipping_address.address_1}

+

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

+
+
+ )} + +
+ + Continue Shopping + + + + Back to Home + +
+
+
+ ) +}