@campxdev/shared 1.11.32-alpha.8 → 1.11.33
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 +1 -1
- package/src/components/Institutions/InsititutionsDialog.tsx +4 -1
- package/src/components/Institutions/InstitutionsDropdown.tsx +4 -1
- package/src/components/LoginForm.tsx +1 -1
- package/src/config/axios.ts +2 -2
- package/src/contexts/Providers.tsx +19 -9
- package/src/hooks/useAuth.ts +4 -3
- package/src/shared-state/PermissionsStore.ts +5 -0
package/package.json
CHANGED
|
@@ -32,9 +32,12 @@ export default function InstitutionsDialog({ close }) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const InstitutionCard = ({ institution }) => {
|
|
35
|
+
const urlTenantKey = window.location.pathname.split('/')[1]
|
|
35
36
|
const handleClick = () => {
|
|
36
37
|
localStorage.setItem('institution_key', institution?.code)
|
|
37
|
-
window.location.replace(
|
|
38
|
+
window.location.replace(
|
|
39
|
+
`${window.location.origin}/${urlTenantKey}/${institution?.code}`,
|
|
40
|
+
)
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
return (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { urlTenantKey } from '../../contexts/Providers'
|
|
1
2
|
import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
|
|
2
3
|
import { SearchSingleSelect } from '../Input/SearchSingleSelect'
|
|
3
4
|
|
|
@@ -7,7 +8,9 @@ export default function SchoolSwitch() {
|
|
|
7
8
|
const handleChange = (value) => {
|
|
8
9
|
if (value) {
|
|
9
10
|
localStorage.setItem('institution_key', value?.value)
|
|
10
|
-
window.location.replace(
|
|
11
|
+
window.location.replace(
|
|
12
|
+
`${window.location.origin}/${urlTenantKey}/${value?.value}`,
|
|
13
|
+
)
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
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
|
|
66
|
+
window.location.href = window.location.origin + `/${res?.data?.subDomain}`
|
|
67
67
|
} catch (err) {
|
|
68
68
|
// eslint-disable-next-line no-console
|
|
69
69
|
console.log(err)
|
package/src/config/axios.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { isDevelopment, isSetup } from '../constants'
|
|
|
6
6
|
import { InstitutionsStore } from '../shared-state/InstitutionsStore'
|
|
7
7
|
|
|
8
8
|
const sessionKey = Cookies.get('campx_session_key')
|
|
9
|
-
const clientId = window.location.
|
|
10
|
-
const institutionId = window.location.pathname.split('/')[
|
|
9
|
+
const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
|
|
10
|
+
const institutionId = window.location.pathname.split('/')[2] ?? 'campx_dev'
|
|
11
11
|
const openPaymentsKey = Cookies.get('campx_open_payments_key')
|
|
12
12
|
|
|
13
13
|
export const formatParams = (params) => {
|
|
@@ -9,11 +9,12 @@ 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'
|
|
12
13
|
import RootModal from './RootModal'
|
|
13
14
|
|
|
14
15
|
export const campxTenantKey = Cookies.get('campx_tenant')
|
|
15
|
-
export const urlTenantKey = window.location.
|
|
16
|
-
export const instituitionKey = window.location.pathname.split('/')[
|
|
16
|
+
export const urlTenantKey = window.location.pathname.split('/')[1]
|
|
17
|
+
export const instituitionKey = window.location.pathname.split('/')[2]
|
|
17
18
|
|
|
18
19
|
export default function Providers({ children }: { children: ReactNode }) {
|
|
19
20
|
const localInstituitionKey = localStorage.getItem('institution_key')
|
|
@@ -32,17 +33,26 @@ export default function Providers({ children }: { children: ReactNode }) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
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
|
+
}
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
}, [])
|
|
44
52
|
|
|
45
|
-
const baseName = getInstituitionKey()
|
|
53
|
+
const baseName = getInstituitionKey()
|
|
54
|
+
? `${urlTenantKey}/${getInstituitionKey()}`
|
|
55
|
+
: urlTenantKey
|
|
46
56
|
|
|
47
57
|
return (
|
|
48
58
|
<BrowserRouter basename={baseName}>
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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'
|
|
6
7
|
import { openRootModal } from '../contexts/RootModal'
|
|
7
8
|
import { AssetsStore, PermissionsStore, UserStore } from '../shared-state'
|
|
8
9
|
import { InstitutionsStore } from '../shared-state/InstitutionsStore'
|
|
@@ -63,7 +64,7 @@ const checkIsAdmin = (user) => {
|
|
|
63
64
|
return isAdmin ? 1 : 0
|
|
64
65
|
}
|
|
65
66
|
const getInstitutionKey = () => {
|
|
66
|
-
const instituitionKey = window.location.pathname.split('/')[
|
|
67
|
+
const instituitionKey = window.location.pathname.split('/')[2]
|
|
67
68
|
if (!instituitionKey) {
|
|
68
69
|
const localInstituitionKey = localStorage.getItem('institution_key')
|
|
69
70
|
if (localInstituitionKey) {
|
|
@@ -90,12 +91,12 @@ function handleInstitutions(institutions) {
|
|
|
90
91
|
if (institutions?.length === 1) {
|
|
91
92
|
if (!insititutionKey) {
|
|
92
93
|
window.location.replace(
|
|
93
|
-
`${window.location.origin}/${institutions[0]?.code}`,
|
|
94
|
+
`${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
|
|
94
95
|
)
|
|
95
96
|
}
|
|
96
97
|
if (insititutionKey !== institutions[0]?.code) {
|
|
97
98
|
window.location.replace(
|
|
98
|
-
`${window.location.origin}/${institutions[0]?.code}`,
|
|
99
|
+
`${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
|
|
99
100
|
)
|
|
100
101
|
}
|
|
101
102
|
InstitutionsStore.update((s) => {
|
|
@@ -1305,6 +1305,11 @@ export enum Permission {
|
|
|
1305
1305
|
CAN_REJECT_LEAVE_REQUESTS = 'can_reject_leave_requests',
|
|
1306
1306
|
CAN_CANCEL_LEAVE_REQUESTS = 'can_cancel_leave_requests',
|
|
1307
1307
|
|
|
1308
|
+
//All Leave Requests
|
|
1309
|
+
VIEW_ALL_LEAVES_REQUESTS = 'can_view_all_leaves_requests',
|
|
1310
|
+
CANCEL_ALL_LEAVE_REQUESTS = 'can_cancel_all_leave_requests',
|
|
1311
|
+
EXPORT_ALL_LEAVE_REQUESTS = 'can_export_all_leave_requests',
|
|
1312
|
+
|
|
1308
1313
|
//Departments
|
|
1309
1314
|
CAN_VIEW_DEPARTMENTS = 'can_view_departments',
|
|
1310
1315
|
CAN_ADD_DEPARTMENTS = 'can_add_departments',
|