@campxdev/shared 1.11.31 → 1.11.32-alpha.1
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/Layout/LayoutWrapper.tsx +22 -4
- package/src/components/Selectors/ExamGroupSelector.tsx +17 -8
- package/src/config/axios.ts +1 -1
- package/src/hooks/useAuth.ts +2 -0
- package/src/layouts/Components/styles.tsx +18 -5
- package/src/shared-state/PermissionsStore.ts +2 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
StyledLeftNavContainer,
|
|
3
3
|
StyledMainContentContainer,
|
|
4
4
|
} from '../../layouts/Components/styles'
|
|
5
|
+
import { PermissionsStore } from '../../shared-state'
|
|
5
6
|
import ErrorBoundary from '../ErrorBoundary'
|
|
6
7
|
import SideNav from './SideNav'
|
|
7
8
|
interface Props {
|
|
@@ -15,12 +16,29 @@ export default function LayoutWrapper({
|
|
|
15
16
|
menu,
|
|
16
17
|
sideMenuHeader,
|
|
17
18
|
}: Props) {
|
|
19
|
+
const permissions = PermissionsStore.useState()
|
|
20
|
+
|
|
18
21
|
return (
|
|
19
22
|
<ErrorBoundary>
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
{!permissions.isHomePageEnabled && (
|
|
24
|
+
<StyledLeftNavContainer>
|
|
25
|
+
<SideNav menuItems={menu as any[]} header={sideMenuHeader} />
|
|
26
|
+
</StyledLeftNavContainer>
|
|
27
|
+
)}
|
|
28
|
+
<StyledMainContentContainer
|
|
29
|
+
style={{
|
|
30
|
+
width: permissions.isHomePageEnabled
|
|
31
|
+
? 'inherit'
|
|
32
|
+
: 'calc(100% - 220px)',
|
|
33
|
+
position: permissions.isHomePageEnabled ? 'unset' : 'fixed',
|
|
34
|
+
marginTop: permissions.isHomePageEnabled ? '10px' : '0px',
|
|
35
|
+
borderRadius: permissions.isHomePageEnabled ? '10px' : '0px',
|
|
36
|
+
border: permissions.isHomePageEnabled ? '1px solid #1212' : 'none',
|
|
37
|
+
height: permissions.isHomePageEnabled
|
|
38
|
+
? 'calc(100vh - 74px)'
|
|
39
|
+
: 'calc(100vh - 64px)',
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
24
42
|
<ErrorBoundary>{children}</ErrorBoundary>
|
|
25
43
|
</StyledMainContentContainer>
|
|
26
44
|
</ErrorBoundary>
|
|
@@ -26,13 +26,13 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
|
|
|
26
26
|
const [prevExamType, setPrevExamType] = useState(null)
|
|
27
27
|
const [prevCourseId, setPrevCourseId] = useState(null)
|
|
28
28
|
let api =
|
|
29
|
-
filters
|
|
29
|
+
filters?.examType !== 'internal'
|
|
30
30
|
? '/exams/exams/exam-groups'
|
|
31
31
|
: '/exams/internal-exams'
|
|
32
32
|
const handleOpen = () => {
|
|
33
33
|
if (filters) {
|
|
34
34
|
if (
|
|
35
|
-
(filters
|
|
35
|
+
(filters?.examType && filters?.examType !== prevExamType) ||
|
|
36
36
|
(filters?.courseId && filters?.courseId !== prevCourseId)
|
|
37
37
|
) {
|
|
38
38
|
setOptions([])
|
|
@@ -46,12 +46,12 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
|
|
|
46
46
|
})
|
|
47
47
|
.then((response) => {
|
|
48
48
|
setOptions(
|
|
49
|
-
filters
|
|
49
|
+
filters?.examType !== 'internal'
|
|
50
50
|
? response.data?.examGroups
|
|
51
51
|
: response.data?.exams,
|
|
52
52
|
)
|
|
53
|
-
setPrevExamType(filters
|
|
54
|
-
setPrevCourseId(filters
|
|
53
|
+
setPrevExamType(filters?.examType)
|
|
54
|
+
setPrevCourseId(filters?.courseId)
|
|
55
55
|
})
|
|
56
56
|
.catch((error) => {
|
|
57
57
|
console.error('Error fetching data from the API:', error)
|
|
@@ -59,9 +59,18 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
|
|
|
59
59
|
}
|
|
60
60
|
} else if (options.length === 0) {
|
|
61
61
|
axios
|
|
62
|
-
.get(api
|
|
62
|
+
.get(api, {
|
|
63
|
+
params: {
|
|
64
|
+
isArchived: 'false',
|
|
65
|
+
isExamPublished: 'true',
|
|
66
|
+
},
|
|
67
|
+
})
|
|
63
68
|
.then((response) => {
|
|
64
|
-
setOptions(
|
|
69
|
+
setOptions(
|
|
70
|
+
filters?.examType !== 'internal'
|
|
71
|
+
? response.data?.examGroups
|
|
72
|
+
: response.data?.exams,
|
|
73
|
+
)
|
|
65
74
|
})
|
|
66
75
|
.catch((error) => {
|
|
67
76
|
console.error('Error fetching data from the API:', error)
|
|
@@ -80,7 +89,7 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
|
|
|
80
89
|
...(allowAll ? [{ value: 'all', label: 'All' }] : []),
|
|
81
90
|
...options.map((item) => ({
|
|
82
91
|
label:
|
|
83
|
-
filters
|
|
92
|
+
filters?.examType != 'internal'
|
|
84
93
|
? item?.groupName
|
|
85
94
|
: item?.displayName,
|
|
86
95
|
value: item?.id,
|
package/src/config/axios.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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.
|
|
9
|
+
const clientId = window.location.origin.split('.')[0] ?? 'campx_dev'
|
|
10
10
|
const institutionId = window.location.pathname.split('/')[2] ?? 'campx_dev'
|
|
11
11
|
const openPaymentsKey = Cookies.get('campx_open_payments_key')
|
|
12
12
|
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -26,6 +26,7 @@ type AuthResponse = {
|
|
|
26
26
|
logo: string
|
|
27
27
|
logo_square: string
|
|
28
28
|
}
|
|
29
|
+
isHomePageEnabled?: boolean
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -235,6 +236,7 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
|
235
236
|
s.isMasterInstitutionUser = res.data?.institutions
|
|
236
237
|
?.map((institution) => institution?.id)
|
|
237
238
|
?.includes(res?.data?.masterInstitutionUniqueId)
|
|
239
|
+
s.isHomePageEnabled = res.data?.isHomePageEnabled
|
|
238
240
|
})
|
|
239
241
|
AssetsStore.update((s) => {
|
|
240
242
|
s.logo = res.data?.assets.logo
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
1
|
import { styled as muiStyled } from '@mui/material'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
3
|
|
|
4
4
|
export const headerHeight = '64px'
|
|
5
5
|
export const sideNavWidth = '220px'
|
|
@@ -59,16 +59,29 @@ export const StyledMainContentContainer = muiStyled('main')(() => ({
|
|
|
59
59
|
overflowY: 'auto',
|
|
60
60
|
|
|
61
61
|
'&::-webkit-scrollbar': {
|
|
62
|
-
width: '0.
|
|
63
|
-
height: '0.
|
|
62
|
+
width: '0.4em',
|
|
63
|
+
height: '0.4em',
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
'&::-webkit-scrollbar-thumb': {
|
|
67
|
-
backgroundColor: 'rgba(0,0,0, 0.
|
|
67
|
+
backgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
68
68
|
borderRadius: '3px',
|
|
69
|
-
|
|
70
69
|
'&:hover': {
|
|
71
70
|
background: 'rgba(0,0,0, 0.4)',
|
|
72
71
|
},
|
|
73
72
|
},
|
|
73
|
+
|
|
74
|
+
// '&::-webkit-scrollbar': {
|
|
75
|
+
// width: '0.6em',
|
|
76
|
+
// height: '0.6em',
|
|
77
|
+
// },
|
|
78
|
+
|
|
79
|
+
// '&::-webkit-scrollbar-thumb': {
|
|
80
|
+
// backgroundColor: 'rgba(0,0,0, 0.3)',
|
|
81
|
+
// borderRadius: '3px',
|
|
82
|
+
|
|
83
|
+
// '&:hover': {
|
|
84
|
+
// background: 'rgba(0,0,0, 0.4)',
|
|
85
|
+
// },
|
|
86
|
+
// },
|
|
74
87
|
}))
|
|
@@ -2047,6 +2047,7 @@ interface IPermissionsStore {
|
|
|
2047
2047
|
masterInstitutionId?: string
|
|
2048
2048
|
isMasterInstitution: boolean
|
|
2049
2049
|
isMasterInstitutionUser?: boolean
|
|
2050
|
+
isHomePageEnabled?: boolean
|
|
2050
2051
|
}
|
|
2051
2052
|
|
|
2052
2053
|
export const PermissionsStore = new Store<IPermissionsStore>({
|
|
@@ -2057,4 +2058,5 @@ export const PermissionsStore = new Store<IPermissionsStore>({
|
|
|
2057
2058
|
masterInstitutionId: null,
|
|
2058
2059
|
isMasterInstitution: false,
|
|
2059
2060
|
isMasterInstitutionUser: false,
|
|
2061
|
+
isHomePageEnabled: false,
|
|
2060
2062
|
})
|