Browse Source

feat module 1,2,4 : product history based on menu display

master
nadia 1 day ago
parent
commit
7d75a194d0
1 changed files with 4 additions and 14 deletions
  1. 4
    14
      src/components/ProductHistoryList/ProductHistoryList.jsx

+ 4
- 14
src/components/ProductHistoryList/ProductHistoryList.jsx View File

2
 import { Box, Typography, IconButton, Pagination, Button } from '@mui/material';
2
 import { Box, Typography, IconButton, Pagination, Button } from '@mui/material';
3
 import { useSelector, useDispatch } from 'react-redux';
3
 import { useSelector, useDispatch } from 'react-redux';
4
 import defaultImage from "../../assets/images/default.png"
4
 import defaultImage from "../../assets/images/default.png"
5
-import { getMenuCollectionTitlesByProductType } from '../../config/menuCollections';
5
+import { isProductInVisibleMenu } from '../../config/menuCollections';
6
 
6
 
7
 import Grid from '@mui/material/Grid2';
7
 import Grid from '@mui/material/Grid2';
8
 
8
 
9
-const normalizeTitle = (title = "") => title.trim().toUpperCase();
10
-
11
-const allowedRecentlyViewedCollections = getMenuCollectionTitlesByProductType();
12
-
13
-const isProductAllowedInRecentlyViewed = (product) => {
14
-  const allowedCollections = allowedRecentlyViewedCollections[product?.productType] || [];
15
-  const normalizedAllowedCollections = allowedCollections.map(normalizeTitle);
16
-
17
-  return product?.collections?.some((collection) =>
18
-    normalizedAllowedCollections.includes(normalizeTitle(collection?.title))
19
-  );
20
-};
9
+// const allowedRecentlyViewedCollections = getMenuCollectionTitlesByProductType();
10
+// const isProductAllowedInRecentlyViewed = (product) => { ... };
21
 
11
 
22
 const ProductHistoryList = () => {
12
 const ProductHistoryList = () => {
23
 
13
 
30
 
20
 
31
       const productHandleList = JSON.parse(localStorage.getItem('amber-product-history')) || []
21
       const productHandleList = JSON.parse(localStorage.getItem('amber-product-history')) || []
32
       const selectedProducts = products.filter((product) => (
22
       const selectedProducts = products.filter((product) => (
33
-        productHandleList.includes(product.handle) && isProductAllowedInRecentlyViewed(product)
23
+        productHandleList.includes(product.handle) && isProductInVisibleMenu(product, products)
34
       )) || []
24
       )) || []
35
 
25
 
36
       // Keep the old history key, but remove products that are no longer available through the menu.
26
       // Keep the old history key, but remove products that are no longer available through the menu.

Loading…
Cancel
Save