import { CheckCircle, MapPin, Package, Receipt, Truck } from "lucide-react"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { cn } from "@/lib/utils"; interface OrderItem { id: string; name: string; image: string; price: number; quantity: number; details?: { label: string; value: string }[]; } interface ShippingAddress { name: string; street: string; city: string; state: string; zipCode: string; country: string; } interface PaymentMethod { type: "card" | "paypal" | "bank"; lastFour?: string; cardBrand?: string; email?: string; } interface OrderSummaryData { orderNumber: string; /** ISO 8601 date (YYYY-MM-DD) */ orderDate: string; status: "confirmed" | "processing" | "shipped" | "delivered"; email: string; items: OrderItem[]; subtotal: number; shipping: number; tax: number; discount?: number; total: number; shippingAddress: ShippingAddress; shippingMethod: string; /** ISO 8601 date range for estimated delivery */ estimatedDeliveryFrom: string; estimatedDeliveryTo?: string; paymentMethod: PaymentMethod; } 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", orderDate: "2024-12-14", status: "confirmed", email: "customer@example.com", items: [ { id: "1", name: "کفش بژ مینیمال", image: "/block-media/shadcnblocks/block/ecommerce/clothes/Minimalist-Beige-Sneakers-2.png", price: 120.0, quantity: 1, details: [ { label: "سایز", value: "42" }, { label: "رنگ", value: "بژ" }, ], }, { id: "2", name: "تاپ آبی گلدوزی", image: "/block-media/shadcnblocks/block/ecommerce/clothes/Woman-in-Embroidered-Blue-Top-2.png", price: 140.0, quantity: 2, details: [ { label: "سایز", value: "M" }, { label: "رنگ", value: "آبی" }, ], }, { id: "3", name: "کلاه فدورا کلاسیک", image: "/block-media/shadcnblocks/block/ecommerce/accessories/Classic-Fedora-Hat-2.png", price: 84.0, quantity: 1, details: [{ label: "سایز", value: "یک سایز" }], }, ], subtotal: 484.0, shipping: 12.0, tax: 38.72, discount: 50.0, total: 484.72, shippingAddress: { name: "علی محمدی", street: "خیابان ولیعصر، پلاک ۱۲۳۴، واحد ۵", city: "تهران", state: "تهران", zipCode: "1415783114", country: "ایران", }, shippingMethod: "ارسال سریع", estimatedDeliveryFrom: "2024-12-18", estimatedDeliveryTo: "2024-12-20", paymentMethod: { type: "card", lastFour: "4242", cardBrand: "Visa", }, }; interface OrderSummary3Props { order?: OrderSummaryData; className?: string; } const OrderSummary3 = ({ order = DEFAULT_ORDER, className, }: OrderSummary3Props) => { return (

سفارش تأیید شد

تأییدیه به{" "} {order.email} {" "} ارسال شد.

شناسه سفارش

{order.orderNumber}

تاریخ سفارش

{formatOrderDate(order.orderDate)}

تحویل

{formatDeliveryEstimate( order.estimatedDeliveryFrom, order.estimatedDeliveryTo, )}

پرداخت

{order.paymentMethod.cardBrand} **** {order.paymentMethod.lastFour}

اقلام شما

{order.items.map((item) => ( {item.name}

{item.name}

{item.details && (

{item.details.map((d, i) => ( {d.label}: {d.value} {i < item.details!.length - 1 && " · "} ))}

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

آدرس ارسال

{order.shippingAddress.name}

{order.shippingAddress.street}

{order.shippingAddress.city}،{" "} {order.shippingAddress.state} کد پستی{" "} {order.shippingAddress.zipCode}

{order.shippingAddress.country}

خلاصه سفارش

جمع جزء {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 { OrderSummary3 };