@campxdev/shared 1.11.32-alpha.5 → 1.11.32-alpha.7

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.11.32-alpha.5",
3
+ "version": "1.11.32-alpha.7",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,4 +1,3 @@
1
- import { urlTenantKey } from '../../contexts/Providers'
2
1
  import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
3
2
  import { SearchSingleSelect } from '../Input/SearchSingleSelect'
4
3
 
@@ -8,9 +7,7 @@ export default function SchoolSwitch() {
8
7
  const handleChange = (value) => {
9
8
  if (value) {
10
9
  localStorage.setItem('institution_key', value?.value)
11
- window.location.replace(
12
- `${window.location.origin}/${urlTenantKey}/${value?.value}`,
13
- )
10
+ window.location.replace(`${window.location.origin}/${value?.value}`)
14
11
  }
15
12
  }
16
13
  const options =
@@ -9,12 +9,11 @@ import { ToastContainer } from '../components'
9
9
  import DialogProvider from '../components/DrawerWrapper/DrawerWrapper'
10
10
  import GlobalNetworkLoadingIndicator from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
11
11
  import ErrorModalProvider from '../components/ErrorModalWrapper/ErrorModalWrapper'
12
- import { isDevelopment } from '../constants'
13
12
  import RootModal from './RootModal'
14
13
 
15
14
  export const campxTenantKey = Cookies.get('campx_tenant')
16
- export const urlTenantKey = window.location.pathname.split('/')[1]
17
- export const instituitionKey = window.location.pathname.split('/')[2]
15
+ export const urlTenantKey = window.location.hostname.split('.')[0]
16
+ export const instituitionKey = window.location.pathname.split('/')[1]
18
17
 
19
18
  export default function Providers({ children }: { children: ReactNode }) {
20
19
  const localInstituitionKey = localStorage.getItem('institution_key')
@@ -33,26 +32,21 @@ export default function Providers({ children }: { children: ReactNode }) {
33
32
  }
34
33
 
35
34
  useEffect(() => {
36
- if (!urlTenantKey) {
37
- if (isDevelopment) {
38
- window.location.replace(window.location.origin + `/aupulse`)
39
- }
40
- if (campxTenantKey)
41
- window.location.replace(window.location.origin + `/${campxTenantKey}`)
42
- } else {
43
- if (!instituitionKey) {
44
- if (localInstituitionKey) {
45
- window.location.replace(
46
- window.location.origin + `/${urlTenantKey}/${localInstituitionKey}`,
47
- )
48
- }
35
+ console.log(instituitionKey, localInstituitionKey)
36
+ if (!instituitionKey) {
37
+ if (localInstituitionKey) {
38
+ window.location.replace(
39
+ window.location.origin + `/${localInstituitionKey}`,
40
+ )
41
+ } else {
42
+ window.location.replace(window.location.origin + `/${urlTenantKey}`)
49
43
  }
50
44
  }
51
45
  }, [])
52
46
 
53
47
  const baseName = getInstituitionKey()
54
- ? `${urlTenantKey}/${getInstituitionKey()}`
55
- : urlTenantKey
48
+ ? `${getInstituitionKey()}`
49
+ : `${urlTenantKey}`
56
50
 
57
51
  return (
58
52
  <BrowserRouter basename={baseName}>
@@ -3,7 +3,6 @@ import { useEffect, useState } from 'react'
3
3
  import { toast } from 'react-toastify'
4
4
  import axios from '../config/axios'
5
5
  import { isDevelopment } from '../constants'
6
- import { urlTenantKey } from '../contexts/Providers'
7
6
  import { openRootModal } from '../contexts/RootModal'
8
7
  import { AssetsStore, PermissionsStore, UserStore } from '../shared-state'
9
8
  import { InstitutionsStore } from '../shared-state/InstitutionsStore'
@@ -64,7 +63,7 @@ const checkIsAdmin = (user) => {
64
63
  return isAdmin ? 1 : 0
65
64
  }
66
65
  const getInstitutionKey = () => {
67
- const instituitionKey = window.location.pathname.split('/')[1] ?? 'campx_dev'
66
+ const instituitionKey = window.location.pathname.split('/')[1]
68
67
  if (!instituitionKey) {
69
68
  const localInstituitionKey = localStorage.getItem('institution_key')
70
69
  if (localInstituitionKey) {
@@ -91,12 +90,12 @@ function handleInstitutions(institutions) {
91
90
  if (institutions?.length === 1) {
92
91
  if (!insititutionKey) {
93
92
  window.location.replace(
94
- `${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
93
+ `${window.location.origin}/${institutions[0]?.code}`,
95
94
  )
96
95
  }
97
96
  if (insititutionKey !== institutions[0]?.code) {
98
97
  window.location.replace(
99
- `${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
98
+ `${window.location.origin}/${institutions[0]?.code}`,
100
99
  )
101
100
  }
102
101
  InstitutionsStore.update((s) => {