Browse Source

allow caca to test and allow collection arragment based on last updated

master
azri 1 week ago
parent
commit
8aec692e0f
5 changed files with 18 additions and 10 deletions
  1. 3
    1
      src/App.js
  2. 9
    4
      src/components/Navbar/Navbar.jsx
  3. 2
    4
      src/index.js
  4. 3
    1
      src/pages/Maintainance.jsx
  5. 1
    0
      src/services/ProductService.js

+ 3
- 1
src/App.js View File

16
 import { useSelector, useDispatch } from 'react-redux';
16
 import { useSelector, useDispatch } from 'react-redux';
17
 import Collection from './pages/Collection';
17
 import Collection from './pages/Collection';
18
 import customerService from './services/CustomerService';
18
 import customerService from './services/CustomerService';
19
+import Maintainance from './pages/Maintainance';
19
 
20
 
20
 const isEmptyObject = (obj) => Object.keys(obj).length === 0 && obj.constructor === Object;
21
 const isEmptyObject = (obj) => Object.keys(obj).length === 0 && obj.constructor === Object;
21
 
22
 
51
       <Navbar />
52
       <Navbar />
52
       <BrowserRouter>
53
       <BrowserRouter>
53
         <Routes>
54
         <Routes>
54
-          <Route path='/' element={<Home />} />
55
+          <Route path='/' element={<Maintainance />} />
56
+          <Route path='/cacatest' element={<Home />} />
55
           <Route path='/login' element={<Login />} />
57
           <Route path='/login' element={<Login />} />
56
 
58
 
57
           <Route path='products'>
59
           <Route path='products'>

+ 9
- 4
src/components/Navbar/Navbar.jsx View File

91
   return data.map(item => {
91
   return data.map(item => {
92
     // Use a Map to store unique collection titles with their corresponding image
92
     // Use a Map to store unique collection titles with their corresponding image
93
     const uniqueCollectionsMap = new Map();
93
     const uniqueCollectionsMap = new Map();
94
-
95
-    item.collection.forEach(({ title, image }) => {
94
+    item.collection.forEach(({ title, image, updatedAt }) => {
96
       if (!uniqueCollectionsMap.has(title)) {
95
       if (!uniqueCollectionsMap.has(title)) {
97
-        uniqueCollectionsMap.set(title, { title, image });
96
+        uniqueCollectionsMap.set(title, { title, image, updatedAt });
98
       }
97
       }
99
     });
98
     });
100
 
99
 
245
     }
244
     }
246
   };
245
   };
247
 
246
 
248
-  const displayCollectionList = (collection, productType) => {
247
+  const displayCollectionList = (collection = [], productType) => {
248
+
249
+    
250
+    collection = collection.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt) )
251
+    console.log(collection)
252
+    debugger
253
+
249
     setDisplayCollection([])
254
     setDisplayCollection([])
250
     setTimeout(() => {
255
     setTimeout(() => {
251
       setDisplayCollection({
256
       setDisplayCollection({

+ 2
- 4
src/index.js View File

18
 
18
 
19
 // JS MODULE STUFF
19
 // JS MODULE STUFF
20
 
20
 
21
-import Maintainance from './pages/Maintainance';
22
 
21
 
23
 /**
22
 /**
24
  * NOTE: Dear future programmer of this project, before you judge me on how fucked up this codebase is, I already take everything into consideration and 
23
  * NOTE: Dear future programmer of this project, before you judge me on how fucked up this codebase is, I already take everything into consideration and 
25
  * this code is really the most spegatthi that you'll ever seen, I only have 2 weeks to figure everything out
24
  * this code is really the most spegatthi that you'll ever seen, I only have 2 weeks to figure everything out
26
  * and somehow I don't have time to refactor everything since the client and management want this project to be done as soon as possible
25
  * and somehow I don't have time to refactor everything since the client and management want this project to be done as soon as possible
27
  * with that in mind, if you have free time, do help me refactor everything. I know I should be the one doing it, but it seems I don't have time to do it
26
  * with that in mind, if you have free time, do help me refactor everything. I know I should be the one doing it, but it seems I don't have time to do it
28
- * and my mind is already elsewhere. I pray that you'll have the perservernce to deal with the refactor and wish you the best of luck, you'll might need all of it
27
+* and my mind is already elsewhere. I pray that you'll have the perservernce to deal with the refactor and wish you the best of luck, you'll might need all of it
29
  * TLDR: to much things to do, to little time time to refactor
28
  * TLDR: to much things to do, to little time time to refactor
30
  */
29
  */
31
 
30
 
32
 const root = ReactDOM.createRoot(document.getElementById('root'));
31
 const root = ReactDOM.createRoot(document.getElementById('root'));
33
 root.render(
32
 root.render(
34
   <Provider store={store}>
33
   <Provider store={store}>
35
-    {/* <App /> */}
36
-    <Maintainance/>
34
+    <App />
37
   </Provider>
35
   </Provider>
38
 );
36
 );
39
 
37
 

+ 3
- 1
src/pages/Maintainance.jsx View File

8
             sx={{
8
             sx={{
9
                 height:"100vh",
9
                 height:"100vh",
10
                 width:"100%",
10
                 width:"100%",
11
-                display:"flex"
11
+                display:"flex",
12
+                position:"absolute",
13
+                zIndex:99999
12
             }}
14
             }}
13
         >
15
         >
14
             <img src={maintananceIMage} style={{width:"100%", margin:"auto auto"}} />
16
             <img src={maintananceIMage} style={{width:"100%", margin:"auto auto"}} />

+ 1
- 0
src/services/ProductService.js View File

46
               image {
46
               image {
47
                 url
47
                 url
48
               }
48
               }
49
+              updatedAt
49
             }
50
             }
50
           }
51
           }
51
           variants(first: 200) {
52
           variants(first: 200) {

Loading…
Cancel
Save