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

feat module 8 : change redirect page for image AMBER HOME

master
nadia 5 дней назад
Родитель
Сommit
5e90cc4a24
2 измененных файлов: 22 добавлений и 5 удалений
  1. 20
    4
      src/components/ProductType/ProductType.jsx
  2. 2
    1
      src/pages/Home.jsx

+ 20
- 4
src/components/ProductType/ProductType.jsx Просмотреть файл

@@ -1,7 +1,13 @@
1 1
 import React from 'react';
2 2
 import { Box, Button, Typography } from '@mui/material';
3 3
 
4
-const ProductType = ({ title, img_url }) => {
4
+const getProductTypeValue = (title = "") => {
5
+  return title?.trim()?.toUpperCase() === "ESSENTIALS" ? "BEAUTY" : title;
6
+}
7
+
8
+const ProductType = ({ title, img_url, clickable = true }) => {
9
+  const productTypeValue = getProductTypeValue(title);
10
+
5 11
   return (
6 12
     <Box
7 13
       sx={{
@@ -29,15 +35,25 @@ const ProductType = ({ title, img_url }) => {
29 35
           alignItems: 'center',
30 36
           color: '#fff', // Text and button color for visibility
31 37
           transition: "all 0.5s ease-in-out",
38
+          cursor: clickable ? 'pointer' : 'default',
32 39
           ":hover":{
33 40
             backgroundColor: 'rgba(0, 0, 0, 0.5)'
34 41
           }
35 42
         }}
36
-        onClick={() => {
37
-          sessionStorage.setItem('amber-select-product-type', title)
43
+        // onClick={() => {
44
+        //   sessionStorage.setItem('amber-select-product-type', title)
45
+        //   sessionStorage.removeItem('amber-select-collection')
46
+        //   window.location.href = '/products'
47
+        // }}
48
+        onClick={clickable ? () => {
49
+          sessionStorage.setItem('amber-select-product-type', productTypeValue)
38 50
           sessionStorage.removeItem('amber-select-collection')
51
+          sessionStorage.removeItem('amber-select-collections')
52
+          if (title?.trim()?.toUpperCase() === "ESSENTIALS") {
53
+            sessionStorage.setItem('amber-select-collections', JSON.stringify(["COSMETICS", "HAND & BODY LOTION"]))
54
+          }
39 55
           window.location.href = '/products'
40
-        }}
56
+        } : undefined}
41 57
       >
42 58
         {/* <Typography variant="h5" gutterBottom sx={{ fontWeight: "600", letterSpacing: 7, marginRight:"-0.4em" }}>
43 59
           {title?.toUpperCase()}

+ 2
- 1
src/pages/Home.jsx Просмотреть файл

@@ -80,7 +80,8 @@ const Home = () => {
80 80
               <ProductType title={'Essentials'} img_url={AmberBeautyWallpaper}/>
81 81
             </Grid>
82 82
             <Grid size={{xs:12, md:6}}>
83
-              <ProductType title={'HOME'} img_url={AmberHomeWallpaper} />
83
+              {/* <ProductType title={'HOME'} img_url={AmberHomeWallpaper} /> */}
84
+              <ProductType title={'Essentials'} img_url={AmberHomeWallpaper} />
84 85
             </Grid>
85 86
           </Grid>
86 87
         </Box>

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