Просмотр исходного кода

feat : change square image and redirect page at homepage

master
nadia 5 дней назад
Родитель
Сommit
1736eedde9
6 измененных файлов: 38 добавлений и 14 удалений
  1. Двоичные данные
      assets-contactsheet.jpg
  2. Двоичные данные
      src/assets/images/squarebanneramberbeauty.jpeg
  3. Двоичные данные
      src/assets/images/squarebanneramberessentials.jpeg
  4. 19
    6
      src/components/ProductList/ProductList.jsx
  5. 13
    5
      src/components/ProductType/ProductType.jsx
  6. 6
    3
      src/pages/Home.jsx

Двоичные данные
assets-contactsheet.jpg Просмотреть файл


Двоичные данные
src/assets/images/squarebanneramberbeauty.jpeg Просмотреть файл


Двоичные данные
src/assets/images/squarebanneramberessentials.jpeg Просмотреть файл


+ 19
- 6
src/components/ProductList/ProductList.jsx Просмотреть файл

42
 function getSelectedCollectionTitles() {
42
 function getSelectedCollectionTitles() {
43
   const storedCollections = sessionStorage.getItem("amber-select-collections");
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
   try {
58
   try {
48
     const collectionTitles = JSON.parse(storedCollections);
59
     const collectionTitles = JSON.parse(storedCollections);
159
 
170
 
160
       // Collection
171
       // Collection
161
       newFilteredProducts = newFilteredProducts.filter((product) => {
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
         if (selectedCollectionTitles.length > 0) {
173
         if (selectedCollectionTitles.length > 0) {
167
           return (
174
           return (
168
             productMatchesSelectedType(product) &&
175
             productMatchesSelectedType(product) &&
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
         if (collection == "all" || collection == "collection") {
186
         if (collection == "all" || collection == "collection") {
176
           return productMatchesSelectedType(product);
187
           return productMatchesSelectedType(product);
177
         } else {
188
         } else {
178
           return (
189
           return (
179
             productMatchesSelectedType(product) &&
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 Просмотреть файл

5
   return title?.trim()?.toUpperCase() === "ESSENTIALS" ? "BEAUTY" : title;
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
   return (
11
   return (
12
     <Box
12
     <Box
49
           sessionStorage.setItem('amber-select-product-type', productTypeValue)
49
           sessionStorage.setItem('amber-select-product-type', productTypeValue)
50
           sessionStorage.removeItem('amber-select-collection')
50
           sessionStorage.removeItem('amber-select-collection')
51
           sessionStorage.removeItem('amber-select-collections')
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
           window.location.href = '/products'
63
           window.location.href = '/products'
56
         } : undefined}
64
         } : undefined}
57
       >
65
       >

+ 6
- 3
src/pages/Home.jsx Просмотреть файл

11
 import ProductType from '../components/ProductType';
11
 import ProductType from '../components/ProductType';
12
 // import NewsLetter from '../components/NewsLetter';
12
 // import NewsLetter from '../components/NewsLetter';
13
 import ProductService from "../services/ProductService"
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
 import AmberClothing from "../assets/images/MAINHEADER-13.webp"
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
 const nowInMalaysia = () => new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Kuala_Lumpur" }))
21
 const nowInMalaysia = () => new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Kuala_Lumpur" }))
19
 const ioiStoreHideFromDate = new Date("2026-08-01T00:00:00+08:00")
22
 const ioiStoreHideFromDate = new Date("2026-08-01T00:00:00+08:00")
78
             </Grid>
81
             </Grid>
79
             <Grid size={{xs:12, md:6}}>
82
             <Grid size={{xs:12, md:6}}>
80
               {/* <ProductType title={'BEAUTY'} img_url={AmberBeautyWallpaper}/> */}
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
             </Grid>
85
             </Grid>
83
             <Grid size={{xs:12, md:6}}>
86
             <Grid size={{xs:12, md:6}}>
84
               {/* <ProductType title={'HOME'} img_url={AmberHomeWallpaper} /> */}
87
               {/* <ProductType title={'HOME'} img_url={AmberHomeWallpaper} /> */}

Загрузка…
Отмена
Сохранить