@autobusal/common 1.14.0 → 1.15.0
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.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useLocation } from 'react-router-dom';
|
|
2
|
+
import { useGetSettings } from '@autobusal/providers/services';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Paths that stay reachable while the site is closed.
|
|
6
|
+
*
|
|
7
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-01
|
|
8
|
+
*
|
|
9
|
+
* Without this the switch is one-way: the holding page replaces the whole
|
|
10
|
+
* router, so /admin goes behind it too and the only way to turn maintenance
|
|
11
|
+
* back OFF is a database edit. Found by actually switching it on and then
|
|
12
|
+
* trying to switch it off again.
|
|
13
|
+
*
|
|
14
|
+
* Staff routes are the exception, not the public site - somebody has to be
|
|
15
|
+
* able to log in and finish the work the site is closed for. Everything a
|
|
16
|
+
* visitor can reach still gets the holding page, including deep links.
|
|
17
|
+
*/
|
|
18
|
+
const ALWAYS_OPEN = [ '/admin', '/account', '/auth' ];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether the holding page should replace the app for the current route.
|
|
22
|
+
*
|
|
23
|
+
* obtapi sends `construction` only while the brand is actually under
|
|
24
|
+
* construction, so its presence is the switch.
|
|
25
|
+
*/
|
|
26
|
+
const useUnderConstruction = (): boolean => {
|
|
27
|
+
const { data: settings } = useGetSettings();
|
|
28
|
+
|
|
29
|
+
const location = useLocation();
|
|
30
|
+
|
|
31
|
+
if (!settings?.construction) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return !ALWAYS_OPEN.some(path => (
|
|
36
|
+
location.pathname === path || location.pathname.startsWith(`${ path }/`)
|
|
37
|
+
));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default useUnderConstruction;
|
package/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ import RouteItem from './RouteItem/RouteItem';
|
|
|
32
32
|
import Row from './Table/Row';
|
|
33
33
|
import Table from './Table/Table';
|
|
34
34
|
import UnderConstruction from './UnderConstruction/UnderConstruction';
|
|
35
|
+
import useUnderConstruction from './UnderConstruction/useUnderConstruction';
|
|
35
36
|
import Viewer from './Viewer/Viewer';
|
|
36
37
|
|
|
37
38
|
export {
|
|
@@ -73,5 +74,6 @@ export {
|
|
|
73
74
|
Row,
|
|
74
75
|
Table,
|
|
75
76
|
UnderConstruction,
|
|
77
|
+
useUnderConstruction,
|
|
76
78
|
Viewer
|
|
77
79
|
};
|