diff --git a/frontend/src/pages/History/History.js b/frontend/src/pages/History/History.js index 4b0691a..3ac932e 100644 --- a/frontend/src/pages/History/History.js +++ b/frontend/src/pages/History/History.js @@ -66,6 +66,20 @@ const History = () => { fetchHistoryData(); }, []); + // Close dropdown when clicking outside + useEffect(() => { + const handleClickOutside = (event) => { + if (showProductDropdown && !event.target.closest('.relative')) { + setShowProductDropdown(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [showProductDropdown]); + const fetchHistoryData = async () => { try { setLoading(true); @@ -248,7 +262,7 @@ const History = () => { {showFilters && (
-
+
@@ -298,17 +337,80 @@ const History = () => {
+
+ + + {showProductDropdown && ( +
+ {uniqueProducts.length === 0 ? ( +
No products available
+ ) : ( + <> +
+ +
+ {uniqueProducts.map(product => ( + + ))} + + )} +
+ )} +
+
+ +
+
@@ -332,10 +434,14 @@ const History = () => {