Просмотр исходного кода

feat module 1,2,4 : fixed product banner display under essentials group - web , mobile view

master
nadia 3 дней назад
Родитель
Сommit
7e1e6f5703

+ 3
- 1
src/components/Navbar/Navbar.jsx Просмотреть файл

@@ -32,6 +32,7 @@ import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
32 32
 import {
33 33
   NAV_MENU_STRUCTURE as SHARED_NAV_MENU_STRUCTURE,
34 34
   buildNavMenuFromProducts,
35
+  getRelatedProductTypes,
35 36
   normalizeTitle,
36 37
 } from "../../config/menuCollections";
37 38
 
@@ -400,9 +401,10 @@ const Navbar = () => {
400 401
   const findCollectionForMenuItem = (productType, item) => {
401 402
     const targetTitles = (item?.titles || []).map(normalizeTitle);
402 403
     const targetHandles = (item?.handles || []).map(normalizeTitle);
404
+    const relatedProductTypeSet = new Set(getRelatedProductTypes(productType));
403 405
 
404 406
     return products
405
-      .filter((product) => product.productType === productType)
407
+      .filter((product) => relatedProductTypeSet.has(normalizeTitle(product?.productType)))
406 408
       .flatMap((product) => product.collections || [])
407 409
       .find((collection) =>
408 410
         targetTitles.includes(normalizeTitle(collection?.title || "")) ||

+ 3
- 1
src/components/Navbar/components/MobileNav/MobileNav.jsx Просмотреть файл

@@ -4,6 +4,7 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
4 4
 import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
5 5
 import Grid from '@mui/material/Grid2';
6 6
 import logoSrc from "../../../../assets/images/amberlogo.png";
7
+import { getRelatedProductTypes } from "../../../../config/menuCollections";
7 8
 
8 9
 const getProductTypeMenuLabel = (productType = "") => {
9 10
   return productType.trim().toUpperCase() === "BEAUTY" ? "Essentials" : productType;
@@ -31,9 +32,10 @@ const MobileNav = ({ open, onClose, menu = [], infomenu = [], products = [] }) =
31 32
   const findCollectionForMenuItem = (productType, item) => {
32 33
     const targetTitles = (item?.titles || []).map(normalizeTitle);
33 34
     const targetHandles = (item?.handles || []).map(normalizeTitle);
35
+    const relatedProductTypeSet = new Set(getRelatedProductTypes(productType));
34 36
 
35 37
     return products
36
-      .filter((product) => product.productType === productType)
38
+      .filter((product) => relatedProductTypeSet.has(normalizeTitle(product?.productType)))
37 39
       .flatMap((product) => product.collections || [])
38 40
       .find((collection) =>
39 41
         targetTitles.includes(normalizeTitle(collection?.title || "")) ||

Загрузка…
Отмена
Сохранить