Explorar el Código

feat : change square image and redirect page at homepage

master
nadia hace 5 días
padre
commit
1736eedde9

BIN
assets-contactsheet.jpg Ver fichero


BIN
src/assets/images/squarebanneramberbeauty.jpeg Ver fichero


BIN
src/assets/images/squarebanneramberessentials.jpeg Ver fichero


+ 19
- 6
src/components/ProductList/ProductList.jsx Ver fichero

@@ -42,7 +42,18 @@ function getAllCollection(data) {
42 42
 function getSelectedCollectionTitles() {
43 43
   const storedCollections = sessionStorage.getItem("amber-select-collections");
44 44
 
45
-  if (!storedCollections) return [];
45
+  if (!storedCollections) {
46
+    const storedCollection = sessionStorage.getItem("amber-select-collection");
47
+
48
+    if (!storedCollection) return [];
49
+
50
+    try {
51
+      const collection = JSON.parse(storedCollection);
52
+      return collection?.title ? [collection.title] : [];
53
+    } catch (error) {
54
+      return [];
55
+    }
56
+  }
46 57
 
47 58
   try {
48 59
     const collectionTitles = JSON.parse(storedCollections);
@@ -159,10 +170,6 @@ const ProductList = ({ size = 99999 }) => {
159 170
 
160 171
       // Collection
161 172
       newFilteredProducts = newFilteredProducts.filter((product) => {
162
-        // Product list now follows collections exposed by the Shopify collection
163
-        // custom.menu_group metafield. 
164
-        if (!productHasVisibleCollection(product)) return false;
165
-
166 173
         if (selectedCollectionTitles.length > 0) {
167 174
           return (
168 175
             productMatchesSelectedType(product) &&
@@ -172,12 +179,18 @@ const ProductList = ({ size = 99999 }) => {
172 179
           );
173 180
         }
174 181
 
182
+        // Product list now follows collections exposed by the Shopify collection
183
+        // custom.menu_group metafield.
184
+        if (!productHasVisibleCollection(product)) return false;
185
+
175 186
         if (collection == "all" || collection == "collection") {
176 187
           return productMatchesSelectedType(product);
177 188
         } else {
178 189
           return (
179 190
             productMatchesSelectedType(product) &&
180
-            product.collections.some((data) => data?.title === collection)
191
+            product.collections.some((data) =>
192
+              normalizeTitle(data?.title || "") === normalizeTitle(collection)
193
+            )
181 194
           );
182 195
         }
183 196
       });

+ 13
- 5
src/components/ProductType/ProductType.jsx Ver fichero

@@ -5,8 +5,8 @@ const getProductTypeValue = (title = "") => {
5 5
   return title?.trim()?.toUpperCase() === "ESSENTIALS" ? "BEAUTY" : title;
6 6
 }
7 7
 
8
-const ProductType = ({ title, img_url, clickable = true }) => {
9
-  const productTypeValue = getProductTypeValue(title);
8
+const ProductType = ({ title, img_url, clickable = true, productType, collectionTitles = [], collectionImage }) => {
9
+const productTypeValue = productType || getProductTypeValue(title);
10 10
 
11 11
   return (
12 12
     <Box
@@ -49,9 +49,17 @@ const ProductType = ({ title, img_url, clickable = true }) => {
49 49
           sessionStorage.setItem('amber-select-product-type', productTypeValue)
50 50
           sessionStorage.removeItem('amber-select-collection')
51 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
-          // }
52
+
53
+          if (collectionTitles.length > 0) {
54
+            sessionStorage.setItem('amber-select-collection', JSON.stringify({
55
+              title,
56
+              image: {
57
+                url: collectionImage || img_url
58
+              }
59
+            }))
60
+            sessionStorage.setItem('amber-select-collections', JSON.stringify(collectionTitles))
61
+          }
62
+
55 63
           window.location.href = '/products'
56 64
         } : undefined}
57 65
       >

+ 6
- 3
src/pages/Home.jsx Ver fichero

@@ -11,9 +11,12 @@ import VideoAds from '../components/VideoAds'
11 11
 import ProductType from '../components/ProductType';
12 12
 // import NewsLetter from '../components/NewsLetter';
13 13
 import ProductService from "../services/ProductService"
14
-import AmberHomeWallpaper from "../assets/images/amberHomeWallpaper.webp";
15
-import AmberBeautyWallpaper from "../assets/images/amberBeautyWallpaper.webp";
14
+// import AmberHomeWallpaper from "../assets/images/amberHomeWallpaper.webp";
15
+import AmberHomeWallpaper from "../assets/images/squarebanneramberessentials.jpeg";
16
+// import AmberBeautyWallpaper from "../assets/images/amberBeautyWallpaper.webp";
17
+import AmberBeautyWallpaper from "../assets/images/squarebanneramberbeauty.jpeg";
16 18
 import AmberClothing from "../assets/images/MAINHEADER-13.webp"
19
+const AmberCosmeticsHeader = "https://cdn.shopify.com/s/files/1/0919/4592/6946/collections/Mask_Group_-4.webp?v=1737761743"
17 20
 
18 21
 const nowInMalaysia = () => new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Kuala_Lumpur" }))
19 22
 const ioiStoreHideFromDate = new Date("2026-08-01T00:00:00+08:00")
@@ -78,7 +81,7 @@ const Home = () => {
78 81
             </Grid>
79 82
             <Grid size={{xs:12, md:6}}>
80 83
               {/* <ProductType title={'BEAUTY'} img_url={AmberBeautyWallpaper}/> */}
81
-              <ProductType title={'Essentials'} img_url={AmberBeautyWallpaper}/>
84
+              <ProductType title={'Cosmetics'} img_url={AmberBeautyWallpaper} productType={'BEAUTY'} collectionTitles={['COSMETIC']} collectionImage={AmberCosmeticsHeader}/>
82 85
             </Grid>
83 86
             <Grid size={{xs:12, md:6}}>
84 87
               {/* <ProductType title={'HOME'} img_url={AmberHomeWallpaper} /> */}

Loading…
Cancelar
Guardar