|
|
@@ -2,22 +2,12 @@ import { useState, useEffect } from 'react';
|
|
2
|
2
|
import { Box, Typography, IconButton, Pagination, Button } from '@mui/material';
|
|
3
|
3
|
import { useSelector, useDispatch } from 'react-redux';
|
|
4
|
4
|
import defaultImage from "../../assets/images/default.png"
|
|
5
|
|
-import { getMenuCollectionTitlesByProductType } from '../../config/menuCollections';
|
|
|
5
|
+import { isProductInVisibleMenu } from '../../config/menuCollections';
|
|
6
|
6
|
|
|
7
|
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
|
12
|
const ProductHistoryList = () => {
|
|
23
|
13
|
|
|
|
@@ -30,7 +20,7 @@ const ProductHistoryList = () => {
|
|
30
|
20
|
|
|
31
|
21
|
const productHandleList = JSON.parse(localStorage.getItem('amber-product-history')) || []
|
|
32
|
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
|
26
|
// Keep the old history key, but remove products that are no longer available through the menu.
|