@autobusal/common 1.13.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/Viewer/types.ts CHANGED
@@ -10,7 +10,12 @@ export interface ViewData {
10
10
  rules?: string
11
11
  notice?: string
12
12
  url?: string
13
- onChange?: (id: 'string' | 'number') => void
13
+ // Edited: Ferjolt Ozuni - Date: 2026-08-01
14
+ // Was `(id: 'string' | 'number')`, i.e. a value that had to literally BE
15
+ // the string "string" or "number" - almost certainly the type names typed
16
+ // by mistake where the types themselves were meant. Every caller was
17
+ // silently working around it by annotating its own parameter as `any`.
18
+ onChange?: (value: string | number) => void
14
19
  }
15
20
 
16
21
  export interface ActionData {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"