@campxdev/shared 1.11.32-alpha.6 → 1.11.32-alpha.8

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.6",
3
+ "version": "1.11.32-alpha.8",
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 =
@@ -63,7 +63,7 @@ export function LoginForm({
63
63
  })
64
64
  Cookies.set('campx_tenant', res?.data?.subDomain)
65
65
  Cookies.set('campx_session_key', res.data?.token)
66
- window.location.href = window.location.origin + `/${res?.data?.subDomain}`
66
+ window.location.href = window.location.origin
67
67
  } catch (err) {
68
68
  // eslint-disable-next-line no-console
69
69
  console.log(err)
@@ -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,17 @@ 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
+ )
49
41
  }
50
42
  }
51
43
  }, [])
52
44
 
53
- const baseName = getInstituitionKey()
54
- ? `${urlTenantKey}/${getInstituitionKey()}`
55
- : urlTenantKey
45
+ const baseName = getInstituitionKey() ? `${getInstituitionKey()}` : ''
56
46
 
57
47
  return (
58
48
  <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'
@@ -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) => {