diff --git a/app/dashboard/orders/[id]/page.tsx b/app/dashboard/orders/[id]/page.tsx index 6261f47..2b4cb70 100644 --- a/app/dashboard/orders/[id]/page.tsx +++ b/app/dashboard/orders/[id]/page.tsx @@ -564,6 +564,57 @@ export default function OrderDetailsPage() { } }; + const copyAllOrderData = async () => { + if (!order) return; + + try { + const lines = []; + + // Order number + lines.push(`Order Number: ${order.orderId}`); + lines.push(''); + + // Order details + lines.push('Order Details:'); + if (order.products && order.products.length > 0) { + order.products.forEach((product) => { + const productName = productNames[product.productId] || 'Unknown Product'; + lines.push(` - ${productName} (Qty: ${product.quantity} @ £${product.pricePerUnit.toFixed(2)} = £${product.totalItemPrice.toFixed(2)})`); + }); + } + + // Shipping + if (order.shippingMethod) { + lines.push(` - Shipping: ${order.shippingMethod.type} (£${order.shippingMethod.price.toFixed(2)})`); + } + + // Discount + if (order.discountAmount && order.discountAmount > 0) { + lines.push(` - Discount: -£${order.discountAmount.toFixed(2)}${order.promotionCode ? ` (Promo: ${order.promotionCode})` : ''}`); + } + + // Subtotal if different from total + if (order.subtotalBeforeDiscount && order.subtotalBeforeDiscount !== order.totalPrice) { + lines.push(` - Subtotal: £${order.subtotalBeforeDiscount.toFixed(2)}`); + } + + // Total + lines.push(` - Total: £${order.totalPrice.toFixed(2)}`); + lines.push(''); + + // Address + lines.push('Address:'); + lines.push(order.pgpAddress || 'N/A'); + + const textToCopy = lines.join('\n'); + await navigator.clipboard.writeText(textToCopy); + toast.success("Order data copied to clipboard!"); + } catch (error) { + toast.error("Failed to copy order data"); + console.error("Copy error:", error); + } + }; + // Helper function to check if order is underpaid const isOrderUnderpaid = (order: Order | null) => { // More robust check - only show underpaid if status is NOT paid and underpayment exists @@ -647,6 +698,15 @@ export default function OrderDetailsPage() {
+