"use client"; import { CheckCircle, Package } from "lucide-react"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; interface OrderItem { id: string; name: string; image: string; price: number; quantity: number; } interface OrderSummaryData { orderNumber: string; items: OrderItem[]; subtotal: number; shipping: number; tax: number; discount?: 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, }, { id: "3", name: "کلاه فدورا کلاسیک", image: "/block-media/shadcnblocks/block/ecommerce/accessories/Classic-Fedora-Hat-2.png", price: 84.0, quantity: 1, }, ], subtotal: 484.0, shipping: 12.0, tax: 38.72, discount: 50.0, total: 484.72, estimatedDeliveryFrom: "2024-12-18", estimatedDeliveryTo: "2024-12-20", }; interface OrderSummary5Props { order?: OrderSummaryData; } const OrderSummary5 = ({ order = DEFAULT_ORDER }: OrderSummary5Props) => { return (
سفارش تأیید شد {order.orderNumber}
{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.tax)}
{order.discount && order.discount > 0 && (
تخفیف −{currencyFormatter.format(order.discount)}
)}
مجموع {currencyFormatter.format(order.total)}
); }; export { OrderSummary5 };