Browse Source

fix mobile nav collection select

master
azri 1 week ago
parent
commit
b25f81ebef

+ 1
- 0
src/App.js View File

40
 
40
 
41
     }
41
     }
42
 
42
 
43
+
43
   }, [])
44
   }, [])
44
 
45
 
45
   return (
46
   return (

+ 1
- 1
src/components/Navbar/Navbar.jsx View File

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

+ 16
- 4
src/components/Navbar/components/MobileNav/MobileNav.jsx View File

36
           }
36
           }
37
         }}
37
         }}
38
         onClick={() => {
38
         onClick={() => {
39
-          sessionStorage.setItem('amber-select-collection', colletion?.title)
39
+          sessionStorage.setItem('amber-select-collection', JSON.stringify(colletion))
40
           window.location.href = `/products`;
40
           window.location.href = `/products`;
41
         }}
41
         }}
42
       >
42
       >
120
             disableGutters={true}
120
             disableGutters={true}
121
             onClick={() => {
121
             onClick={() => {
122
               sessionStorage.setItem('amber-select-product-type', productType)
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
             sx={{
128
             sx={{
127
               backgroundColor: "rgba(0,0,0,0)",
129
               backgroundColor: "rgba(0,0,0,0)",
132
               aria-controls="panel1-content"
134
               aria-controls="panel1-content"
133
               id="panel1-header"
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
             </AccordionSummary>
148
             </AccordionSummary>
137
             <AccordionDetails>
149
             <AccordionDetails>
138
               {(collection?.length > 0) &&
150
               {(collection?.length > 0) &&

+ 1
- 1
src/components/PageTitle/PageTitle.jsx View File

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

+ 4
- 3
src/components/ProductList/ProductList.jsx View File

90
         const collectionList = getAllCollection(newFilteredProducts);
90
         const collectionList = getAllCollection(newFilteredProducts);
91
         setCollectionFilterOption(collectionList);
91
         setCollectionFilterOption(collectionList);
92
       } else {
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
   const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
161
   const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
161
 
162
 
162
     return (
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
         <a href={`/products/${handle}`} style={{textDecoration:"none",color:"#000"}}>
166
         <a href={`/products/${handle}`} style={{textDecoration:"none",color:"#000"}}>
166
           <Box
167
           <Box
319
             let maxPrice = maxVariantPrice.amount
320
             let maxPrice = maxVariantPrice.amount
320
             let maxPriceCurrency = maxVariantPrice.currencyCode
321
             let maxPriceCurrency = maxVariantPrice.currencyCode
321
 
322
 
322
-            let img_url = images[0]?.url
323
+            let img_url = images[0].url
323
             let collection_name = collections[0]?.title
324
             let collection_name = collections[0]?.title
324
 
325
 
325
             if (index < size) {
326
             if (index < size) {

+ 1
- 0
src/index.js View File

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

+ 9
- 3
src/pages/Products/index.jsx View File

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

Loading…
Cancel
Save