DDBS UI
commerce

Order Confirmation

The order confirmation page: items, totals, delivery address and estimated arrival, read from session storage.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/store-confirmation-view.json
Dependencies:lucide-react
Fullscreen

Usage

store-confirmation-view-example.tsx
"use client";

import { useEffect, useState } from "react";
import { ConfirmationView, writeStorage, type ConfirmationOrder } from "@dbs/ui";
import { IMG, IMG2, StoreScope, fmt } from "./_store";

const KEY = "catalog-demo-order";

const ORDER: ConfirmationOrder = {
  id: "DBS-48213",
  email: "amine@example.com",
  lines: [
    { name: "Atlas Canvas Tote", color: "Sand", size: "One size", quantity: 2, unitPrice: 390, image: IMG },
    { name: "Souk Linen Shirt", color: "Indigo", size: "M", quantity: 1, unitPrice: 640, image: IMG2 },
  ],
  subtotal: 1420,
  discount: 142,
  promo: "WELCOME10",
  shipping: 0,
  tax: 213,
  total: 1278,
  address: {
    name: "Amine El Idrissi",
    line1: "14 Rue Moulay Youssef",
    city: "Casablanca",
    region: "Casablanca-Settat",
    postal: "20000",
    country: "Morocco",
  },
  deliveryLabel: "Standard delivery",
  eta: "Thu 19 Nov to Mon 23 Nov",
};

// ConfirmationView reads the order the checkout stored in session storage.
export default function StoreConfirmationViewExample() {
  const [ready, setReady] = useState(false);
  useEffect(() => {
    writeStorage("session", KEY, ORDER);
    setReady(true);
  }, []);
  return (
    <StoreScope minHeight={0} className="rounded-none border-0">
      {ready && (
        <ConfirmationView
          orderKey={KEY}
          formatPrice={fmt}
          hrefs={{ products: "#" }}
          emptyBody="Place an order to see your confirmation here."
          taxLabel="VAT (20%)"
          taxIncluded
          itemImageSize={[60, 80]}
          classes={{ itemImage: "h-20 w-[60px] rounded-lg bg-[var(--store-tile)] object-cover" }}
        />
      )}
    </StoreScope>
  );
}