@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.8.49-alpha.1",
3
+ "version": "1.8.49-alpha.3",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -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 insititutionCode = instituitionKey
22
- ? instituitionKey
23
- : localInstituitionKey
24
- ? localInstituitionKey
25
- : null
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 = `${urlTenantKey}/${insititutionCode}`
53
+ const baseName = getInstituitionKey()
54
+ ? `${urlTenantKey}/${getInstituitionKey()}`
55
+ : urlTenantKey
43
56
 
44
57
  return (
45
58
  <BrowserRouter basename={baseName}>