Browse Source

fix product selected link

master
azri 1 week ago
parent
commit
7d9ef2b26b
1 changed files with 47 additions and 46 deletions
  1. 47
    46
      src/components/ProductSelected/ProductSelected.jsx

+ 47
- 46
src/components/ProductSelected/ProductSelected.jsx View File

38
   };
38
   };
39
 
39
 
40
 
40
 
41
-  const renderProduct = (id, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
41
+  const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
42
 
42
 
43
     return (
43
     return (
44
       <Grid item size={{ xs: 6, sm: 6, md: 3 }}>
44
       <Grid item size={{ xs: 6, sm: 6, md: 3 }}>
45
-
46
-        <Box
47
-          onClick={() => { window.location.href = `/products/${id}` }}
48
-          sx={{
49
-            overflow: 'hidden',
50
-            position: 'relative',
51
-            cursor: 'pointer'
52
-          }}
53
-
54
-        >
55
-          <img
56
-            src={img_url}
57
-            alt={title}
58
-            style={{
59
-              width: '100%',
60
-              aspectRatio: '3 / 4',
61
-              objectFit: 'cover',
62
-              objectPosition: 'top center'
45
+        <a
46
+          href={`/products/${handle}`}
47
+          style={{
48
+            color: 'black',
49
+            textDecoration: 'none'
50
+          }}>
51
+          <Box
52
+            sx={{
53
+              overflow: 'hidden',
54
+              position: 'relative',
55
+              cursor: 'pointer',
63
             }}
56
             }}
64
-          />
65
 
57
 
66
-          {/* <Button sx={{ position: "absolute", top: 20, left: 20, boxShadow: 0 }} variant="contained">
58
+          >
59
+            <img
60
+              src={img_url}
61
+              alt={title}
62
+              style={{
63
+                width: '100%',
64
+                aspectRatio: '3 / 4',
65
+                objectFit: 'cover',
66
+                objectPosition: 'top center'
67
+              }}
68
+            />
69
+
70
+            {/* <Button sx={{ position: "absolute", top: 20, left: 20, boxShadow: 0 }} variant="contained">
67
             NEW
71
             NEW
68
           </Button> */}
72
           </Button> */}
69
 
73
 
70
-          <Box sx={{ pb: 5, pt: 3 }}>
71
-            <Typography variant="body1" sx={{ fontWeight: "400", mb: 1 }}>
72
-              {collection_name}
73
-            </Typography>
74
-            <Typography variant="h5" sx={{ fontWeight: "bolder", mb: 1 }}>
75
-              {title}
76
-            </Typography>
77
-            <Typography variant="body1" sx={{ fontWeight: "400" }}>
78
-              {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
79
-            </Typography>
80
-            <Typography variant="body1" sx={{ mt: 2 }}>
81
-              {extra_desc}
82
-            </Typography>
74
+            <Box sx={{ pb: 5, pt: 3 }}>
75
+              <Typography variant="body1" sx={{ fontWeight: "400", mb: 1 }}>
76
+                {collection_name}
77
+              </Typography>
78
+              <Typography variant="h5" sx={{ fontWeight: "bolder", mb: 1 }}>
79
+                {title}
80
+              </Typography>
81
+              <Typography variant="body1" sx={{ fontWeight: "400" }}>
82
+                {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
83
+              </Typography>
84
+              <Typography variant="body1" sx={{ mt: 2 }}>
85
+                {extra_desc}
86
+              </Typography>
87
+            </Box>
83
           </Box>
88
           </Box>
84
-        </Box>
89
+        </a>
85
       </Grid>
90
       </Grid>
86
     )
91
     )
87
 
92
 
97
       <Grid size={{ xs: 12, md: 4 }} sx={{ mx: "auto", display: "flex", alignItems: "center", justifyContent: "center", my: 4 }}>
102
       <Grid size={{ xs: 12, md: 4 }} sx={{ mx: "auto", display: "flex", alignItems: "center", justifyContent: "center", my: 4 }}>
98
         <ChevronLeftIcon
103
         <ChevronLeftIcon
99
           style={{
104
           style={{
100
-            cursor:"pointer",
101
-            color:"#B7B7B7"
105
+            cursor: "pointer",
106
+            color: "#B7B7B7"
102
           }}
107
           }}
103
           onClick={swipeToLeft}
108
           onClick={swipeToLeft}
104
         />
109
         />
105
-        <Typography variant="h4" sx={{mx:2}}>
110
+        <Typography variant="h4" sx={{ mx: 2 }}>
106
           NEW IN
111
           NEW IN
107
         </Typography>
112
         </Typography>
108
 
113
 
109
         <KeyboardArrowRightIcon
114
         <KeyboardArrowRightIcon
110
           style={{
115
           style={{
111
-            cursor:"pointer",
112
-            color:"#B7B7B7"
116
+            cursor: "pointer",
117
+            color: "#B7B7B7"
113
           }}
118
           }}
114
           onClick={swipeToRight}
119
           onClick={swipeToRight}
115
         />
120
         />
129
       >
134
       >
130
         {filterProducts.map((product, index) => {
135
         {filterProducts.map((product, index) => {
131
 
136
 
132
-          let { id, title, images, collections, minVariantPrice, maxVariantPrice, productType, variants } = product
137
+          let { handle, title, images, collections, minVariantPrice, maxVariantPrice, productType, variants } = product
133
 
138
 
134
           let minPrice = minVariantPrice.amount
139
           let minPrice = minVariantPrice.amount
135
           let minPriceCurrency = minVariantPrice.currencyCode
140
           let minPriceCurrency = minVariantPrice.currencyCode
139
           let img_url = images[0]?.url
144
           let img_url = images[0]?.url
140
           let collection_name = collections[0]?.title
145
           let collection_name = collections[0]?.title
141
 
146
 
142
-          // ID
143
-          const parts = id.split('/');
144
-          let prodID = parts[parts.length - 1];
145
-
146
           return (
147
           return (
147
             <SwiperSlide>
148
             <SwiperSlide>
148
-              {renderProduct(prodID, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, "")}
149
+              {renderProduct(handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, "")}
149
             </SwiperSlide>
150
             </SwiperSlide>
150
           )
151
           )
151
 
152
 

Loading…
Cancel
Save