From 3c179e62d7869a568711801d42f33c4f36d560b1 Mon Sep 17 00:00:00 2001 From: iFixKart Dev Date: Wed, 18 Nov 2026 18:38:03 +0530 Subject: [PATCH] fix(orders): polish responsive header, uniform button heights, and outside-click invoice dropdown --- app/(admin)/orders/page.tsx | 151 +++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 64 deletions(-) diff --git a/app/(admin)/orders/page.tsx b/app/(admin)/orders/page.tsx index 574b718..d176182 100644 --- a/app/(admin)/orders/page.tsx +++ b/app/(admin)/orders/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useEffect, useMemo, useState, type ReactNode } from 'react'; +import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'; import { Plus, RefreshCw, @@ -192,6 +192,7 @@ export default function OrderIntelligencePage() { const [changeReason, setChangeReason] = useState(''); const [updating, setUpdating] = useState(false); const [showInvoiceMenu, setShowInvoiceMenu] = useState(false); + const invoiceMenuRef = useRef(null); const [showCreateOrderModal, setShowCreateOrderModal] = useState(false); const [buyerName, setBuyerName] = useState(''); @@ -729,6 +730,17 @@ export default function OrderIntelligencePage() { fetchCatalogProductsAndSkus(); }, []); + useEffect(() => { + if (!showInvoiceMenu) return; + const handleOutsideClick = (e: MouseEvent) => { + if (invoiceMenuRef.current && !invoiceMenuRef.current.contains(e.target as Node)) { + setShowInvoiceMenu(false); + } + }; + document.addEventListener('mousedown', handleOutsideClick); + return () => document.removeEventListener('mousedown', handleOutsideClick); + }, [showInvoiceMenu]); + const handleInspectOrder = async (id: string) => { setSelectedOrderId(id); setDetailLoading(true); @@ -1081,72 +1093,75 @@ export default function OrderIntelligencePage() {
Failed to load order details.
) : (
-
-
-
-

{formatOrderDate(detailData.created_at)}

-
- {renderStatusBadge(detailData.status)} - - {(detailData.payment_status || 'UNPAID').replace('_', ' ')} +
+ {/* Header: Date, Badges & Action Toolbar */} +
+
+ {formatOrderDate(detailData.created_at)} + {detailData.invoice_no && ( + + 📄 {detailData.invoice_no} - {detailData.is_discounted && ( - - 🏷️ Discounted Order - - )} - {detailData.invoice_no && ( - - 📄 {detailData.invoice_no} - - )} -
+ )}
+ +
+ {renderStatusBadge(detailData.status)} + + {(detailData.payment_status || 'UNPAID').replace('_', ' ')} + + {detailData.is_discounted && ( + + 🏷️ Discounted Order + + )} +
+ {!showStatusForm && ( -
+
{/* Print Invoice with Dropdown */} -
- - - Print Invoice - - +
+
+ + + Print Invoice + + +
{showInvoiceMenu && ( -
setShowInvoiceMenu(false)} - > +
setShowInvoiceMenu(false)} - className="flex items-center gap-2 px-3 py-2 text-foreground hover:bg-muted transition-colors" + className="flex items-center gap-2.5 px-3 py-2 text-foreground hover:bg-muted rounded-md transition-colors" > - - + {/* Print Shipping Slip */} {detailData.shipping_label_url && ( - - Print Shipping Slip + + Print Shipping Slip )} -