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

feat module 5 : add specific date to hide the shop location

master
nadia 5 часов назад
Родитель
Сommit
a790d543c9
1 измененных файлов: 9 добавлений и 7 удалений
  1. 9
    7
      src/pages/Home.jsx

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

@@ -15,18 +15,18 @@ import AmberHomeWallpaper from "../assets/images/amberHomeWallpaper.webp";
15 15
 import AmberBeautyWallpaper from "../assets/images/amberBeautyWallpaper.webp";
16 16
 import AmberClothing from "../assets/images/MAINHEADER-13.webp"
17 17
 
18
+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")
20
+
18 21
 const stores = [
19 22
   {
20
-    // name: "AMBER IOI STORE",
21
-    // address: "IOI City Mall",
22 23
     name: "IOI CITY MALL",
23 24
     address: "G-67 IOI CITY MALL, PUTRAJAYA",
24 25
     image: "/AMBERIOISTORE.jpeg",
25
-    directionUrl: "https://www.google.com/maps/search/?api=1&query=IOI%20City%20Mall%20Putrajaya"
26
+    directionUrl: "https://www.google.com/maps/search/?api=1&query=IOI%20City%20Mall%20Putrajaya",
27
+    hideAfter: ioiStoreHideFromDate
26 28
   },
27 29
   {
28
-    // name: "AMBER SWM STORE",
29
-    // address: "Wangsa Walk Mall",
30 30
     name: "WANGSA WALK MALL",
31 31
     address: "LOT G-77, WANGSA WALK MALL, KUALA LUMPUR",
32 32
     image: "/AMBERSWMSTORE.jpeg",
@@ -35,6 +35,7 @@ const stores = [
35 35
 ]
36 36
 
37 37
 const Home = () => {
38
+  const visibleStores = stores.filter(({ hideAfter }) => !hideAfter || nowInMalaysia() < hideAfter)
38 39
 
39 40
   React.useEffect(()=>{
40 41
     ProductService.getProducts();
@@ -129,10 +130,11 @@ const Home = () => {
129 130
             spacing={2}
130 131
             sx={{
131 132
               maxWidth: 1200,
132
-              mx: "auto"
133
+              mx: "auto",
134
+              justifyContent: "center"
133 135
             }}
134 136
           >
135
-            {stores.map(({ name, address, image, directionUrl }) => (
137
+            {visibleStores.map(({ name, address, image, directionUrl }) => (
136 138
               <Grid key={name} size={{ xs: 12, md: 6 }}>
137 139
                 <Box
138 140
                   sx={{

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