瀏覽代碼

feat module 8 : change redirect page for image AMBER HOME

master
nadia 5 天之前
父節點
當前提交
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
 import React from 'react';
1
 import React from 'react';
2
 import { Box, Button, Typography } from '@mui/material';
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
   return (
11
   return (
6
     <Box
12
     <Box
7
       sx={{
13
       sx={{
29
           alignItems: 'center',
35
           alignItems: 'center',
30
           color: '#fff', // Text and button color for visibility
36
           color: '#fff', // Text and button color for visibility
31
           transition: "all 0.5s ease-in-out",
37
           transition: "all 0.5s ease-in-out",
38
+          cursor: clickable ? 'pointer' : 'default',
32
           ":hover":{
39
           ":hover":{
33
             backgroundColor: 'rgba(0, 0, 0, 0.5)'
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
           sessionStorage.removeItem('amber-select-collection')
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
           window.location.href = '/products'
55
           window.location.href = '/products'
40
-        }}
56
+        } : undefined}
41
       >
57
       >
42
         {/* <Typography variant="h5" gutterBottom sx={{ fontWeight: "600", letterSpacing: 7, marginRight:"-0.4em" }}>
58
         {/* <Typography variant="h5" gutterBottom sx={{ fontWeight: "600", letterSpacing: 7, marginRight:"-0.4em" }}>
43
           {title?.toUpperCase()}
59
           {title?.toUpperCase()}

+ 2
- 1
src/pages/Home.jsx 查看文件

80
               <ProductType title={'Essentials'} img_url={AmberBeautyWallpaper}/>
80
               <ProductType title={'Essentials'} img_url={AmberBeautyWallpaper}/>
81
             </Grid>
81
             </Grid>
82
             <Grid size={{xs:12, md:6}}>
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
             </Grid>
85
             </Grid>
85
           </Grid>
86
           </Grid>
86
         </Box>
87
         </Box>

Loading…
取消
儲存