@campxdev/shared 1.11.7-1.alpha.8 → 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
|
@@ -62,7 +62,9 @@ export function LoginForm({
|
|
|
62
62
|
},
|
|
63
63
|
})
|
|
64
64
|
Cookies.set('campx_session_key', res.data?.token)
|
|
65
|
-
|
|
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
|
package/src/config/axios.ts
CHANGED
|
@@ -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
|
-
?
|
|
10
|
+
? Cookies.get('campx_tenant')
|
|
11
11
|
: window.location.hostname.split('.')[0]
|
|
12
|
-
const institutionCode =
|
|
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
|
-
?
|
|
18
|
-
: window.location.hostname.split('.')[0]
|
|
17
|
+
? Cookies.get('campx_tenant')
|
|
18
|
+
: window.location.hostname.split('.')[0]
|
|
19
19
|
export const urlTenantKey = isDevelopment
|
|
20
|
-
?
|
|
21
|
-
: window.location.hostname.split('.')[0]
|
|
22
|
-
export const instituitionKey =
|
|
23
|
-
|
|
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 =
|
|
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 = `/${
|
|
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
|
}, [])
|