"use client"; import { CheckCircle } from "lucide-react"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Separator } from "@/components/ui/separator"; interface OrderItem { id: string; name: string; image: string; price: number; quantity: number; } interface OrderSummaryData { orderNumber: string; items: OrderItem[]; subtotal: number; shipping: number; total: number; /** ISO 8601 date range for estimated delivery */ estimatedDeliveryFrom: string; estimatedDeliveryTo?: string; } const currencyFormatter = new Intl.NumberFormat("fa-IR", { style: "currency", currency: "IRR", }); const dateFormatter = new Intl.DateTimeFormat("fa-IR", { year: "numeric", month: "long", day: "numeric", }); const formatOrderDate = (isoDate: string) => dateFormatter.format(new Date(isoDate + "T12:00:00")); const formatDeliveryEstimate = (from: string, to?: string) => { if (to && to !== from) { return `${formatOrderDate(from)} تا ${formatOrderDate(to)}`; } return formatOrderDate(from); }; const DEFAULT_ORDER: OrderSummaryData = { orderNumber: "ORD-2024-78432", items: [ { id: "1", name: "کفش بژ مینیمال", image: "/block-media/shadcnblocks/block/ecommerce/clothes/Minimalist-Beige-Sneakers-2.png", price: 120.0, quantity: 1, }, { id: "2", name: "تاپ آبی گلدوزی", image: "/block-media/shadcnblocks/block/ecommerce/clothes/Woman-in-Embroidered-Blue-Top-2.png", price: 140.0, quantity: 2, }, ], subtotal: 400.0, shipping: 12.0, total: 412.0, estimatedDeliveryFrom: "2024-12-18", estimatedDeliveryTo: "2024-12-20", }; interface OrderSummary6Props { order?: OrderSummaryData; } const OrderSummary6 = ({ order = DEFAULT_ORDER }: OrderSummary6Props) => { return (
سفارش تأیید شد! سفارش{" "} {order.orderNumber} {" "} · تحویل{" "} {formatDeliveryEstimate( order.estimatedDeliveryFrom, order.estimatedDeliveryTo, )}
{order.items.map((item) => (
{item.name}

{item.name}

تعداد: {item.quantity.toLocaleString("fa-IR")}

{currencyFormatter.format(item.price * item.quantity)}

))}
جمع جزء {currencyFormatter.format(order.subtotal)}
هزینه ارسال {order.shipping === 0 ? "رایگان" : currencyFormatter.format(order.shipping)}
مجموع {currencyFormatter.format(order.total)}
); }; export { OrderSummary6 };