@campxdev/shared 1.11.30 → 1.11.32
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
|
@@ -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)
|
|
@@ -80,7 +80,7 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
|
|
|
80
80
|
...(allowAll ? [{ value: 'all', label: 'All' }] : []),
|
|
81
81
|
...options.map((item) => ({
|
|
82
82
|
label:
|
|
83
|
-
filters
|
|
83
|
+
filters?.examType != 'internal'
|
|
84
84
|
? item?.groupName
|
|
85
85
|
: item?.displayName,
|
|
86
86
|
value: item?.id,
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
} from '@mui/material'
|
|
15
15
|
import { ReactNode, useEffect, useRef, useState } from 'react'
|
|
16
16
|
import { toast } from 'react-toastify'
|
|
17
|
-
import axios
|
|
17
|
+
import axios from '../../config/axios'
|
|
18
18
|
import { buffertoCSV } from '../../utils'
|
|
19
|
-
import { DeleteButton, EditButton } from '../IconButtons'
|
|
20
19
|
import { useErrorModal } from '../ErrorModalWrapper/ErrorModalWrapper'
|
|
20
|
+
import { DeleteButton, EditButton } from '../IconButtons'
|
|
21
21
|
const animatedImage = require('./AnimatedUploadFile.gif')
|
|
22
22
|
|
|
23
23
|
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
@@ -80,7 +80,8 @@ interface UploadFileDialogProps {
|
|
|
80
80
|
sampleFileDownloadUrl?: string
|
|
81
81
|
uploadUrl: string
|
|
82
82
|
successMessage?: string
|
|
83
|
-
refetchFn
|
|
83
|
+
refetchFn?: (res: any) => void
|
|
84
|
+
onUpload?: () => void
|
|
84
85
|
postBody?: { [key: string]: string }
|
|
85
86
|
}
|
|
86
87
|
|
|
@@ -95,6 +96,7 @@ export default function UploadFileDialog({
|
|
|
95
96
|
refetchFn,
|
|
96
97
|
sampleFileDownloadUrl,
|
|
97
98
|
postBody = {},
|
|
99
|
+
onUpload,
|
|
98
100
|
}: UploadFileDialogProps) {
|
|
99
101
|
const inputRef: any = useRef(null)
|
|
100
102
|
const [loading, setLoading] = useState(false)
|
|
@@ -115,6 +117,7 @@ export default function UploadFileDialog({
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
const handleOnUpload = () => {
|
|
120
|
+
onUpload && onUpload()
|
|
118
121
|
if (!file) return ``
|
|
119
122
|
const formData = new FormData()
|
|
120
123
|
formData.append('file', file)
|
|
@@ -129,7 +132,7 @@ export default function UploadFileDialog({
|
|
|
129
132
|
.post(uploadUrl, formData)
|
|
130
133
|
.then((res) => {
|
|
131
134
|
setLoading(false)
|
|
132
|
-
refetchFn(res)
|
|
135
|
+
refetchFn && refetchFn(res)
|
|
133
136
|
setOpen(false)
|
|
134
137
|
toast.success(successMessage ?? 'Successful')
|
|
135
138
|
setFile(null)
|
|
@@ -6,3 +6,14 @@ export default function getUrlParams() {
|
|
|
6
6
|
}
|
|
7
7
|
return params
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
export const createSearchParams = (query: { [key: string]: string }) => {
|
|
11
|
+
const searchParams = new URLSearchParams()
|
|
12
|
+
|
|
13
|
+
for (const key in query) {
|
|
14
|
+
if (query[key] !== null && query[key] !== 'all') {
|
|
15
|
+
searchParams.append(key, encodeURIComponent(query[key]))
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return query
|
|
19
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { createSearchParams } from './getUrlParams'
|
|
2
2
|
export { default as arrayPadEnd } from './arrayPadEnd'
|
|
3
|
-
export { default as romanize } from './romanize'
|
|
4
3
|
export { default as buffertoCSV } from './buffertoCSV'
|
|
4
|
+
export { default as getUrlParams } from './getUrlParams'
|
|
5
|
+
export { default as romanize } from './romanize'
|
|
5
6
|
|
|
7
|
+
export { default as onLogout } from './logout'
|
|
6
8
|
export { default as withRouteWrapper } from './withRouteWrapper'
|
|
7
9
|
export { default as withSuspense } from './withSuspense'
|
|
8
|
-
|
|
10
|
+
|
|
11
|
+
export { createSearchParams }
|