Bladeren bron

fix mobile nav collection select

master
azri 1 week geleden
bovenliggende
commit
b25f81ebef

+ 1
- 0
src/App.js Bestand weergeven

@@ -40,6 +40,7 @@ function App() {
40 40
 
41 41
     }
42 42
 
43
+
43 44
   }, [])
44 45
 
45 46
   return (

+ 1
- 1
src/components/Navbar/Navbar.jsx Bestand weergeven

@@ -206,7 +206,7 @@ const Navbar = () => {
206 206
             }
207 207
           }}
208 208
           onClick={() => {
209
-            sessionStorage.setItem('amber-select-collection', colletion?.title)
209
+            sessionStorage.setItem('amber-select-collection', JSON.stringify(colletion))
210 210
             sessionStorage.setItem('amber-select-product-type', displayCollection.productType)
211 211
             window.location.href = `/products`;
212 212
           }}

+ 16
- 4
src/components/Navbar/components/MobileNav/MobileNav.jsx Bestand weergeven

@@ -36,7 +36,7 @@ const MobileNav = ({ open, onClose, menu = [] }) => {
36 36
           }
37 37
         }}
38 38
         onClick={() => {
39
-          sessionStorage.setItem('amber-select-collection', colletion?.title)
39
+          sessionStorage.setItem('amber-select-collection', JSON.stringify(colletion))
40 40
           window.location.href = `/products`;
41 41
         }}
42 42
       >
@@ -120,8 +120,10 @@ const MobileNav = ({ open, onClose, menu = [] }) => {
120 120
             disableGutters={true}
121 121
             onClick={() => {
122 122
               sessionStorage.setItem('amber-select-product-type', productType)
123
-              sessionStorage.removeItem('amber-select-collection')
124
-              if (collection?.length == 0) window.location.href = `/products`;
123
+              if (collection?.length == 0) {
124
+                window.location.href = `/products`;
125
+                sessionStorage.removeItem('amber-select-collection')
126
+              } 
125 127
             }}
126 128
             sx={{
127 129
               backgroundColor: "rgba(0,0,0,0)",
@@ -132,7 +134,17 @@ const MobileNav = ({ open, onClose, menu = [] }) => {
132 134
               aria-controls="panel1-content"
133 135
               id="panel1-header"
134 136
             >
135
-              <Typography variant="body1" sx={{ fontWeight: "500" }} >{productType?.toUpperCase()}</Typography>
137
+              <Typography 
138
+                onClick={() => {
139
+                  sessionStorage.setItem('amber-select-product-type', productType)
140
+                  window.location.href = `/products`;
141
+                  sessionStorage.removeItem('amber-select-collection')
142
+                }} 
143
+                variant="body1" 
144
+                sx={{ fontWeight: "500" }}
145
+              >
146
+                {productType?.toUpperCase()}
147
+              </Typography>
136 148
             </AccordionSummary>
137 149
             <AccordionDetails>
138 150
               {(collection?.length > 0) &&

+ 1
- 1
src/components/PageTitle/PageTitle.jsx Bestand weergeven

@@ -7,6 +7,7 @@ const PageTitle = ({title = "", image = null}) => {
7 7
 
8 8
   return (
9 9
     <Box
10
+      className="animate__animated animate__fadeIn"
10 11
       sx={{
11 12
         position: "relative",
12 13
         minHeight: "300px",
@@ -17,7 +18,6 @@ const PageTitle = ({title = "", image = null}) => {
17 18
         textAlign: "center",
18 19
         overflow: "hidden", // Ensures the dim layer stays inside the box
19 20
         display:"flex",
20
-        mt:5
21 21
       }}
22 22
     >
23 23
       {/* Overlay */}

+ 4
- 3
src/components/ProductList/ProductList.jsx Bestand weergeven

@@ -90,7 +90,8 @@ const ProductList = ({ size = 99999 }) => {
90 90
         const collectionList = getAllCollection(newFilteredProducts);
91 91
         setCollectionFilterOption(collectionList);
92 92
       } else {
93
-        setCollection(sessionStorage.getItem('amber-select-collection'))
93
+        const selectedColletion = JSON.parse(sessionStorage.getItem('amber-select-collection'))
94
+        setCollection(selectedColletion?.title)
94 95
       }
95 96
 
96 97
     }
@@ -160,7 +161,7 @@ const ProductList = ({ size = 99999 }) => {
160 161
   const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
161 162
 
162 163
     return (
163
-      <Grid className="animate__animated animate__fadeIn" de item size={{ xs: 6, sm: 6, md: 3 }}>
164
+      <Grid className="animate__animated animate__fadeIn" item size={{ xs: 6, sm: 6, md: 3 }}>
164 165
 
165 166
         <a href={`/products/${handle}`} style={{textDecoration:"none",color:"#000"}}>
166 167
           <Box
@@ -319,7 +320,7 @@ const ProductList = ({ size = 99999 }) => {
319 320
             let maxPrice = maxVariantPrice.amount
320 321
             let maxPriceCurrency = maxVariantPrice.currencyCode
321 322
 
322
-            let img_url = images[0]?.url
323
+            let img_url = images[0].url
323 324
             let collection_name = collections[0]?.title
324 325
 
325 326
             if (index < size) {

+ 1
- 0
src/index.js Bestand weergeven

@@ -16,6 +16,7 @@ import '@fontsource/roboto/500.css';
16 16
 import '@fontsource/roboto/700.css';
17 17
 // import reportWebVitals from './reportWebVitals';
18 18
 
19
+// JS MODULE STUFF
19 20
 
20 21
 const root = ReactDOM.createRoot(document.getElementById('root'));
21 22
 root.render(

+ 9
- 3
src/pages/Products/index.jsx Bestand weergeven

@@ -8,13 +8,18 @@ import Feature from '../../components/Feature'
8 8
 
9 9
 const Products = () => {
10 10
 
11
+  const [collection, setCollection] = useState(null)
12
+
11 13
   useEffect(()=>{
12 14
     
13 15
     // if user come from select collection
14 16
     if(sessionStorage.getItem('amber-select-product-type')){
15 17
 
16
-      let selectProductType = sessionStorage.getItem('amber-select-product-type')
17
-
18
+      if(sessionStorage.getItem('amber-select-collection')){
19
+        let selectCollection = JSON.parse(sessionStorage.getItem('amber-select-collection'))
20
+        setCollection(selectCollection)
21
+      }
22
+      
18 23
     }else{
19 24
       window.location.href = '/'
20 25
     }
@@ -24,7 +29,7 @@ const Products = () => {
24 29
   return (
25 30
     <>
26 31
       <Box sx={{
27
-        mt:15,
32
+        mt:10,
28 33
         px: {
29 34
           xs: 2,
30 35
           md: 12,
@@ -36,6 +41,7 @@ const Products = () => {
36 41
           lg: 10
37 42
         }
38 43
       }}>
44
+        {collection && <PageTitle title={collection?.title} image={collection?.image?.url} /> }
39 45
         <ProductList />
40 46
         <SocialMedia />
41 47
         <Feature />

Laden…
Annuleren
Opslaan