@campxdev/shared 1.10.92 → 1.10.94
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 +3 -3
- package/src/components/Institutions/InstitutionsDropdown.tsx +2 -2
- package/src/components/MyProfile/MyProfile.tsx +2 -2
- package/src/components/ReportHeader.tsx +24 -13
- package/src/components/index.ts +1 -0
- package/src/config/axios.ts +2 -2
- package/src/config/axiosXTenant.ts +4 -0
- package/src/contexts/Providers.tsx +1 -1
- package/src/hooks/useAuth.ts +4 -4
- package/src/shared-state/InstitutionsStore.ts +1 -1
- package/src/utils/getUrlParams.ts +3 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Box, TextField, Typography, styled } from '@mui/material'
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
|
|
4
4
|
import Image from '../Image/Image'
|
|
5
5
|
|
|
6
|
-
export default function
|
|
6
|
+
export default function InstitutionsDialog({ close }) {
|
|
7
7
|
const [searchText, setSearchText] = useState('')
|
|
8
|
-
const { institutions } =
|
|
8
|
+
const { institutions } = InstitutionsStore.useState((s) => s)
|
|
9
9
|
const filteredInstitutions = institutions.filter((item) =>
|
|
10
10
|
item.name.toLowerCase().includes(searchText.toLowerCase()),
|
|
11
11
|
)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { urlTenantKey } from '../../contexts/Providers'
|
|
2
|
-
import {
|
|
2
|
+
import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
|
|
3
3
|
import { SearchSingleSelect } from '../Input/SearchSingleSelect'
|
|
4
4
|
|
|
5
5
|
export default function SchoolSwitch() {
|
|
6
|
-
const { current, institutions } =
|
|
6
|
+
const { current, institutions } = InstitutionsStore.useState((s) => s)
|
|
7
7
|
|
|
8
8
|
const handleChange = (value) => {
|
|
9
9
|
if (value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box, Chip, Container, Typography } from '@mui/material'
|
|
2
2
|
import { useQuery } from 'react-query'
|
|
3
3
|
import axios from '../../config/axios'
|
|
4
|
-
import {
|
|
4
|
+
import { InstitutionsStore } from '../../shared-state/InstitutionsStore'
|
|
5
5
|
import PageHeader from '../PageHeader'
|
|
6
6
|
import Spinner from '../Spinner'
|
|
7
7
|
import Education from './Education/Education'
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import Workshop from './Workshop/Workshop'
|
|
20
20
|
|
|
21
21
|
const MyProfile = ({ close }) => {
|
|
22
|
-
const { institutions, current } =
|
|
22
|
+
const { institutions, current } = InstitutionsStore.useState((s) => s)
|
|
23
23
|
|
|
24
24
|
const { data, isLoading } = useQuery('dashboard', () =>
|
|
25
25
|
axios.get('/square/users/dashboard').then((res) => res?.data),
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import { Box, Typography } from '@mui/material'
|
|
1
|
+
import { Box, SxProps, Typography } from '@mui/material'
|
|
2
|
+
import { Variant } from '@mui/material/styles/createTypography'
|
|
2
3
|
|
|
4
|
+
interface TypographyList {
|
|
5
|
+
text: string
|
|
6
|
+
sx?: SxProps
|
|
7
|
+
variant?: Variant
|
|
8
|
+
}
|
|
3
9
|
interface ReportHeaderProps {
|
|
10
|
+
typographyList?: TypographyList[]
|
|
4
11
|
logo: any
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
imageSize?: string
|
|
13
|
+
containerSx?: SxProps
|
|
7
14
|
}
|
|
8
15
|
|
|
9
|
-
export
|
|
16
|
+
export default function ReportHeader({
|
|
17
|
+
logo,
|
|
18
|
+
typographyList,
|
|
19
|
+
containerSx,
|
|
20
|
+
imageSize,
|
|
21
|
+
}: ReportHeaderProps) {
|
|
10
22
|
return (
|
|
11
23
|
<Box
|
|
12
24
|
sx={{
|
|
@@ -14,24 +26,23 @@ export const ReportHeader = ({ logo, address, title }: ReportHeaderProps) => {
|
|
|
14
26
|
flexDirection: 'column',
|
|
15
27
|
alignItems: 'center',
|
|
16
28
|
gap: '5px',
|
|
29
|
+
...containerSx,
|
|
17
30
|
}}
|
|
18
31
|
>
|
|
19
32
|
<img
|
|
20
33
|
style={{
|
|
21
|
-
height: '
|
|
34
|
+
height: imageSize ? imageSize : '80px',
|
|
22
35
|
objectFit: 'contain',
|
|
23
36
|
}}
|
|
24
37
|
src={logo}
|
|
25
38
|
/>
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
</Typography>
|
|
34
|
-
)}
|
|
40
|
+
{typographyList &&
|
|
41
|
+
typographyList.map((s) => (
|
|
42
|
+
<Typography variant={s.variant} sx={{ ...s.sx }}>
|
|
43
|
+
{s.text}
|
|
44
|
+
</Typography>
|
|
45
|
+
))}
|
|
35
46
|
</Box>
|
|
36
47
|
)
|
|
37
48
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export { default as NoDataIllustration } from './NoDataIllustration'
|
|
|
58
58
|
export { PageContent } from './PageContent'
|
|
59
59
|
export { default as PageHeader } from './PageHeader'
|
|
60
60
|
export { default as useConfirm } from './PopupConfirm/useConfirm'
|
|
61
|
+
export { default as ReportHeader } from './ReportHeader'
|
|
61
62
|
export { default as ReportPageHeader } from './ReportPageHeader'
|
|
62
63
|
export { default as Spinner } from './Spinner'
|
|
63
64
|
export { default as PaymentStepper } from './Stepper'
|
package/src/config/axios.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Cookies from 'js-cookie'
|
|
|
3
3
|
import { toast } from 'react-toastify'
|
|
4
4
|
import { NetworkStore } from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
|
|
5
5
|
import { isDevelopment, isSetup } from '../constants'
|
|
6
|
-
import {
|
|
6
|
+
import { InstitutionsStore } from '../shared-state/InstitutionsStore'
|
|
7
7
|
|
|
8
8
|
const sessionKey = Cookies.get('campx_session_key')
|
|
9
9
|
const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
|
|
@@ -31,7 +31,7 @@ let axios = Axios.create({
|
|
|
31
31
|
|
|
32
32
|
axios.interceptors.request.use(
|
|
33
33
|
function (config: AxiosRequestConfig) {
|
|
34
|
-
const { current } =
|
|
34
|
+
const { current } = InstitutionsStore.getRawState()
|
|
35
35
|
if (current) {
|
|
36
36
|
config.headers['x-institution-code'] = current.code
|
|
37
37
|
} else {
|
|
@@ -7,6 +7,7 @@ import { formatParams } from './axios'
|
|
|
7
7
|
const sessionKey = Cookies.get('campx_session_key')
|
|
8
8
|
const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
|
|
9
9
|
const evaluatorKey = Cookies.get('campx_evaluator_key')
|
|
10
|
+
const openPaymentsKey = Cookies.get('campx_open_payments_key')
|
|
10
11
|
|
|
11
12
|
const axiosTenant = Axios.create({
|
|
12
13
|
baseURL: process.env.REACT_APP_API_HOST,
|
|
@@ -20,6 +21,9 @@ const axiosTenant = Axios.create({
|
|
|
20
21
|
...(evaluatorKey && {
|
|
21
22
|
campx_evaluator_key: evaluatorKey,
|
|
22
23
|
}),
|
|
24
|
+
...(openPaymentsKey && {
|
|
25
|
+
campx_open_payments_key: openPaymentsKey,
|
|
26
|
+
}),
|
|
23
27
|
},
|
|
24
28
|
})
|
|
25
29
|
|
|
@@ -35,7 +35,7 @@ export default function Providers({ children }: { children: ReactNode }) {
|
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (!urlTenantKey) {
|
|
37
37
|
if (isDevelopment) {
|
|
38
|
-
window.location.replace(window.location.origin + `/
|
|
38
|
+
window.location.replace(window.location.origin + `/aupulse`)
|
|
39
39
|
}
|
|
40
40
|
if (campxTenantKey)
|
|
41
41
|
window.location.replace(window.location.origin + `/${campxTenantKey}`)
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { isDevelopment } from '../constants'
|
|
|
6
6
|
import { urlTenantKey } from '../contexts/Providers'
|
|
7
7
|
import { openRootModal } from '../contexts/RootModal'
|
|
8
8
|
import { AssetsStore, PermissionsStore, UserStore } from '../shared-state'
|
|
9
|
-
import {
|
|
9
|
+
import { InstitutionsStore } from '../shared-state/InstitutionsStore'
|
|
10
10
|
|
|
11
11
|
const url = window.location.origin
|
|
12
12
|
|
|
@@ -97,7 +97,7 @@ function handleInstitutions(institutions) {
|
|
|
97
97
|
`${window.location.origin}/${urlTenantKey}/${institutions[0]?.code}`,
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
InstitutionsStore.update((s) => {
|
|
101
101
|
s.current = institutions[0]
|
|
102
102
|
s.institutions = institutions
|
|
103
103
|
})
|
|
@@ -125,7 +125,7 @@ function handleInstitutions(institutions) {
|
|
|
125
125
|
},
|
|
126
126
|
})
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
InstitutionsStore.update((s) => {
|
|
129
129
|
s.institutions = institutions
|
|
130
130
|
s.current = institutions.find((item) => item.code === insititutionKey)
|
|
131
131
|
})
|
|
@@ -174,7 +174,7 @@ const loginErrorHandler = ({
|
|
|
174
174
|
function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
175
175
|
const [loading, setLoading] = useState<boolean>(false)
|
|
176
176
|
const [data, setData] = useState(null)
|
|
177
|
-
const { current } =
|
|
177
|
+
const { current } = InstitutionsStore.useState()
|
|
178
178
|
|
|
179
179
|
const appInit = async () => {
|
|
180
180
|
setLoading(true)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export default function getUrlParams() {
|
|
2
2
|
const urlSearchParams = new URLSearchParams(window.location.search)
|
|
3
3
|
const params = Object.fromEntries(urlSearchParams.entries())
|
|
4
|
+
for (const i in params) {
|
|
5
|
+
params[i] = decodeURIComponent(params[i])
|
|
6
|
+
}
|
|
4
7
|
return params
|
|
5
8
|
}
|