@riosst100/pwa-marketplace 3.1.6 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "3.1.6",
4
+ "version": "3.1.8",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -0,0 +1 @@
1
+ export { default } from './maintenancePage';
@@ -0,0 +1,37 @@
1
+ import React, { Fragment } from 'react';
2
+ import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
3
+ import defaultClasses from './maintenancePage.module.css';
4
+ import { useStyle } from '@magento/venia-ui/lib/classify';
5
+
6
+ const MaintenancePage = props => {
7
+
8
+ const classes = useStyle(defaultClasses);
9
+
10
+ return (
11
+ <>
12
+ <head>
13
+ <meta charset="UTF-8" />
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
+ <title>We'll Be Back Soon</title>
16
+ </head>
17
+ <body className={classes.body}>
18
+ <div className={classes.container}>
19
+ <img src="https://seller-preprod.tcgcollective.co/media/logo/default/FullLogo_Transparent_NoBuffer_14_.png" alt="Logo" className={classes.logo} />
20
+ <br />
21
+ <h1 className={classes.h1}>We're Temporarily Offline</h1>
22
+ <img src="https://seller-preprod.tcgcollective.co/media/maintenance.webp" alt="Logo" className={classes.logo} />
23
+ <p className={classes.p}>
24
+ Our website is currently undergoing scheduled maintenance. <br/>
25
+ We should be back shortly. Thank you for your patience.
26
+ </p>
27
+ <div className={classes.footer}>
28
+ &copy; <span id="year">{new Date().getFullYear()}</span> TCG Collective. All rights reserved.
29
+ {/* | <a href="mailto:support@yourdomain.com">Contact Support</a> */}
30
+ </div>
31
+ </div>
32
+ </body>
33
+ </>
34
+ );
35
+ }
36
+
37
+ export default MaintenancePage;
@@ -0,0 +1,45 @@
1
+ .body {
2
+ background-color: #f3f4f6;
3
+ color: #333;
4
+ font-family: 'Arial', sans-serif;
5
+ text-align: center;
6
+ /* padding: 50px; */
7
+ display: flex;
8
+ justify-content: center; /* Horizontal center */
9
+ align-items: center; /* Vertical center */
10
+ height: 100vh; /* Full height layar */
11
+ margin: 0;
12
+ }
13
+ .container {
14
+ max-width: 700px;
15
+ margin: auto;
16
+ padding: 30px;
17
+ background: #fff;
18
+ border-radius: 12px;
19
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
20
+ }
21
+ .h1 {
22
+ font-size: 2.5em;
23
+ color: #1a202c;
24
+ padding: 20px;
25
+ }
26
+ .p {
27
+ font-size: 16px;
28
+ line-height: 1.6;
29
+ color: #4a5568;
30
+ padding: 20px;
31
+ }
32
+ .logo {
33
+ width: 200px;
34
+ display: inline-block;
35
+ margin-bottom: 10px;
36
+ }
37
+ .footer {
38
+ margin-top: 20px;
39
+ font-size: 14px;
40
+ color: #718096;
41
+ }
42
+ .footer a {
43
+ color: #3182ce;
44
+ text-decoration: none;
45
+ }
@@ -11,6 +11,7 @@ import { CACHE_PERSIST_PREFIX } from '@magento/peregrine/lib/Apollo/constants';
11
11
  import getLinks from '@magento/peregrine/lib/Apollo/links';
12
12
  import typePolicies from '@magento/peregrine/lib/Apollo/policies';
13
13
  import { BrowserPersistence } from '@magento/peregrine/lib/util';
14
+ import axios from 'axios';
14
15
 
15
16
  const isServer = !globalThis.document;
16
17
  const storage = new BrowserPersistence();
@@ -47,6 +48,7 @@ export const useAdapter = props => {
47
48
  }
48
49
 
49
50
  const [initialized, setInitialized] = useState(false);
51
+ const [isMaintenance, setIsMaintenance] = useState(false);
50
52
 
51
53
  const apiBase = useMemo(
52
54
  () => apiUrl || new URL('/graphql', origin).toString(),
@@ -186,13 +188,33 @@ export const useAdapter = props => {
186
188
  })();
187
189
  }, [apolloClient, initialized]);
188
190
 
191
+ useEffect(() => {
192
+ if (initialized) return;
193
+
194
+ // immediately invoke this async function
195
+ (async () => {
196
+ axios.get(apiBase + '?query=%7B%20__schema%20%7B%20queryType%20%7B%20fields%20%7B%20name%20description%20type%20%7B%20name%20kind%20%7D%20%7D%20%7D%20%7D%20%7D').then((response) => {
197
+ setIsMaintenance(false)
198
+ }).catch((error) => {
199
+ const status = error.response.status;
200
+ if (status != 200) {
201
+ setIsMaintenance(true)
202
+ } else {
203
+ setIsMaintenance(false)
204
+ }
205
+ });
206
+ })();
207
+ }, [apiBase,initialized]);
208
+
189
209
  return {
190
210
  apolloProps,
211
+ isMaintenance,
191
212
  initialized,
192
213
  reduxProps,
193
214
  routerProps,
194
215
  styleProps,
195
- urlHasStoreCode
216
+ urlHasStoreCode,
217
+ apiBase
196
218
  };
197
219
  };
198
220
 
@@ -7,7 +7,8 @@ import App, { AppContextProvider } from '@magento/venia-ui/lib/components/App';
7
7
  import StoreCodeRoute from '@magento/venia-ui/lib/components/StoreCodeRoute';
8
8
  import { useWebsiteByIp } from '@riosst100/pwa-marketplace/src/talons/WebsiteByIp/useWebsiteByIp';
9
9
  import { BrowserPersistence } from '@magento/peregrine/lib/util';
10
-
10
+ import MaintenancePage from '@riosst100/pwa-marketplace/src/components/MaintenancePage';
11
+ import axios from 'axios';
11
12
 
12
13
  const storage = new BrowserPersistence();
13
14
 
@@ -20,11 +21,33 @@ const Adapter = props => {
20
21
  apolloProps,
21
22
  initialized,
22
23
  reduxProps,
23
- routerProps
24
+ routerProps,
25
+ isMaintenance,
26
+ apiBase
24
27
  } = talonProps;
25
28
 
29
+ // console.log('isMaintenance',isMaintenance)
30
+
31
+ // useEffect(() => {
32
+ // const fetchData = async () => {
33
+ // axios.get(apiBase).then((response) => {
34
+ // // setIsMaintenance(false)
35
+ // }).catch((error) => {
36
+ // const status = error.response.status;
37
+ // if (status != 200) {
38
+ // console.log('status',status)
39
+ // return <MaintenancePage />;
40
+ // // setIsMaintenance(true)
41
+ // }
42
+ // });
43
+ // };
44
+
45
+ // fetchData();
46
+
26
47
 
27
-
48
+ // if (isMaintenance) {
49
+ // return <MaintenancePage />;
50
+ // }
28
51
 
29
52
  const websiteCodes = [];
30
53
  const websiteStores = useMemo(() => ({}), []);
@@ -148,6 +171,10 @@ const Adapter = props => {
148
171
  return null;
149
172
  }
150
173
 
174
+ if (isMaintenance) {
175
+ return <MaintenancePage />;
176
+ }
177
+
151
178
  const children = props.children || <App />;
152
179
 
153
180
  return !verifyUserIp && (
@@ -198,9 +198,6 @@ export const useWebsiteSwitcher = (props = {}) => {
198
198
 
199
199
  const newPath = pathName ? `/${pathName}${newSearchParams}` : (accessBaseWebsite ? `/${pathName}${accessBaseWebsite}` : '');
200
200
 
201
- // await apolloClient.clearCacheData(apolloClient, 'cart');
202
- // await removeCart();
203
-
204
201
  if (newWebsiteCode) {
205
202
  globalThis.location.assign(`/${newWebsiteCode}${newPath || ''}`);
206
203
  } else {