@campxdev/shared 1.11.7-1.alpha.7 → 1.11.7-1.alpha.9

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.7-1.alpha.7",
3
+ "version": "1.11.7-1.alpha.9",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -62,7 +62,9 @@ export function LoginForm({
62
62
  },
63
63
  })
64
64
  Cookies.set('campx_session_key', res.data?.token)
65
- window.location.href = `/${res.data.subDomain}/${res.data.institutionCode}`
65
+ Cookies.set('campx_tenant', res.data?.subDomain)
66
+ Cookies.set('campx_institution', res.data?.institutionCode)
67
+ window.location.href = `/${res.data.institutionCode}`
66
68
  //window.location.reload()
67
69
  } catch (err) {
68
70
  // eslint-disable-next-line no-console
@@ -1,5 +1,4 @@
1
1
  import { createContext, ReactNode, useState } from 'react'
2
- import MuiThemeProvider from '../../theme/MuiThemeProvider'
3
2
  import PopupConfirm from './PopupConfirm'
4
3
 
5
4
  interface ConfirmContextProps {
@@ -31,12 +30,10 @@ const ConfirmContextProvider = ({ children }) => {
31
30
  })
32
31
 
33
32
  return (
34
- <MuiThemeProvider>
35
- <ConfirmContext.Provider value={{ confirm, setConfirm }}>
36
- {children}
37
- <PopupConfirm />
38
- </ConfirmContext.Provider>
39
- </MuiThemeProvider>
33
+ <ConfirmContext.Provider value={{ confirm, setConfirm }}>
34
+ {children}
35
+ <PopupConfirm />
36
+ </ConfirmContext.Provider>
40
37
  )
41
38
  }
42
39
 
@@ -7,11 +7,9 @@ const isDevelopment = process.env.NODE_ENV == 'development'
7
7
 
8
8
  const sessionKey = Cookies.get('campx_session_key')
9
9
  const tenantCode = isDevelopment
10
- ? window.location.pathname.split('/')[1]
10
+ ? Cookies.get('campx_tenant')
11
11
  : window.location.hostname.split('.')[0]
12
- const institutionCode = isDevelopment
13
- ? window.location.pathname.split('/')[2]
14
- : window.location.pathname.split('/')[1]
12
+ const institutionCode = window.location.pathname.split('/')[1]
15
13
 
16
14
  const openPaymentsKey = Cookies.get('campx_open_payments_key')
17
15
 
@@ -14,51 +14,38 @@ import RootModal from './RootModal'
14
14
  const isDevelopment = process.env.NODE_ENV == 'development'
15
15
 
16
16
  export const campxTenantKey = isDevelopment
17
- ? window.location.pathname.split('/')[1]
18
- : window.location.hostname.split('.')[0] ?? Cookies.get('campx_tenant')
17
+ ? Cookies.get('campx_tenant')
18
+ : window.location.hostname.split('.')[0]
19
19
  export const urlTenantKey = isDevelopment
20
- ? window.location.pathname.split('/')[1]
21
- : window.location.hostname.split('.')[0] ?? Cookies.get('campx_tenant')
22
- export const instituitionKey = isDevelopment
23
- ? window.location.pathname.split('/')[2]
24
- : window.location.pathname.split('/')[1]
20
+ ? Cookies.get('campx_tenant')
21
+ : window.location.hostname.split('.')[0]
22
+ export const instituitionKey =
23
+ window.location.pathname.split('/')[1] ?? Cookies.get('campx_institution')
25
24
 
26
25
  export default function Providers({ children }: { children: ReactNode }) {
27
- const sessionKey = Cookies.get('campx_session_key')
28
26
  var baseName = '/'
29
27
  var tenantCode
30
- var institutionCode
28
+ var institutionCode =
29
+ window.location.pathname.split('/')[1] ?? Cookies.get('campx_institution')
31
30
 
32
31
  if (isDevelopment) {
33
- tenantCode = window.location.pathname.split('/')[1]
34
- institutionCode = window.location.pathname.split('/')[2]
32
+ tenantCode = Cookies.get('campx_tenant')
35
33
  if (
36
34
  tenantCode &&
37
35
  institutionCode &&
38
36
  window.location.pathname !== '/auth/login'
39
37
  ) {
40
- baseName = `/${tenantCode}/${institutionCode}`
38
+ baseName = `/${institutionCode}`
41
39
  }
42
40
  } else {
43
41
  tenantCode = window.location.hostname.split('.')[0]
44
- institutionCode = window.location.pathname.split('/')[1]
45
-
46
42
  if (institutionCode && window.location.pathname !== '/auth/login') {
47
43
  baseName = `/${institutionCode}`
48
44
  }
49
45
  }
50
46
 
51
47
  useEffect(() => {
52
- if (
53
- isDevelopment &&
54
- location.pathname === '/' &&
55
- institutionCode &&
56
- tenantCode
57
- ) {
58
- window.location.replace(
59
- window.location.origin + `/${tenantCode}/${institutionCode}`,
60
- )
61
- } else if (location.pathname === '/' && institutionCode) {
48
+ if (location.pathname === '/' && institutionCode && tenantCode) {
62
49
  window.location.replace(window.location.origin + `/${institutionCode}`)
63
50
  }
64
51
  }, [])