@campxdev/shared 1.8.49-alpha.1 → 1.8.49-alpha.3
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 +1 -1
- package/src/contexts/Providers.tsx +19 -6
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import DialogProvider from '../components/DrawerWrapper/DrawerWrapper'
|
|
|
10
10
|
import GlobalNetworkLoadingIndicator from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
|
|
11
11
|
import FreshChatButton from '../components/Layout/Header/HeaderActions/FreshChatButton'
|
|
12
12
|
import RootModal from './RootModal'
|
|
13
|
+
import { isDevelopment } from '../constants'
|
|
13
14
|
|
|
14
15
|
export const campxTenantKey = Cookies.get('campx_tenant')
|
|
15
16
|
export const urlTenantKey = window.location.pathname.split('/')[1]
|
|
@@ -18,14 +19,24 @@ export const instituitionKey = window.location.pathname.split('/')[2]
|
|
|
18
19
|
export default function Providers({ children }: { children: ReactNode }) {
|
|
19
20
|
const localInstituitionKey = localStorage.getItem('institution_key')
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const getInstituitionKey = () => {
|
|
23
|
+
if (instituitionKey) {
|
|
24
|
+
return instituitionKey
|
|
25
|
+
} else {
|
|
26
|
+
if (!urlTenantKey) return null
|
|
27
|
+
if (localInstituitionKey) {
|
|
28
|
+
return localInstituitionKey
|
|
29
|
+
} else {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
useEffect(() => {
|
|
28
36
|
if (!urlTenantKey) {
|
|
37
|
+
if (isDevelopment) {
|
|
38
|
+
window.location.replace(window.location.origin + `/campx_dev`)
|
|
39
|
+
}
|
|
29
40
|
if (campxTenantKey)
|
|
30
41
|
window.location.replace(window.location.origin + `/${campxTenantKey}`)
|
|
31
42
|
} else {
|
|
@@ -39,7 +50,9 @@ export default function Providers({ children }: { children: ReactNode }) {
|
|
|
39
50
|
}
|
|
40
51
|
}, [])
|
|
41
52
|
|
|
42
|
-
const baseName =
|
|
53
|
+
const baseName = getInstituitionKey()
|
|
54
|
+
? `${urlTenantKey}/${getInstituitionKey()}`
|
|
55
|
+
: urlTenantKey
|
|
43
56
|
|
|
44
57
|
return (
|
|
45
58
|
<BrowserRouter basename={baseName}>
|