@campxdev/shared 1.10.17 → 1.10.19
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
|
@@ -16,6 +16,7 @@ import { DeleteButton, EditButton } from '../IconButtons'
|
|
|
16
16
|
import { ReactNode, useEffect, useRef, useState } from 'react'
|
|
17
17
|
import { toast } from 'react-toastify'
|
|
18
18
|
import axios, { axiosErrorToast } from '../../config/axios'
|
|
19
|
+
import { buffertoCSV } from '../../utils'
|
|
19
20
|
const animatedImage = require('./AnimatedUploadFile.gif')
|
|
20
21
|
|
|
21
22
|
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
@@ -75,6 +76,7 @@ interface UploadFileDialogProps {
|
|
|
75
76
|
children?: ReactNode
|
|
76
77
|
dialogTitle: ReactNode | string
|
|
77
78
|
sampleFileUrl?: string
|
|
79
|
+
sampleFileDownloadUrl?: string
|
|
78
80
|
uploadUrl: string
|
|
79
81
|
successMessage?: string
|
|
80
82
|
refetchFn: () => void
|
|
@@ -90,6 +92,7 @@ export default function UploadFileDialog({
|
|
|
90
92
|
sampleFileUrl,
|
|
91
93
|
successMessage,
|
|
92
94
|
refetchFn,
|
|
95
|
+
sampleFileDownloadUrl,
|
|
93
96
|
postBody = {},
|
|
94
97
|
}: UploadFileDialogProps) {
|
|
95
98
|
const inputRef: any = useRef(null)
|
|
@@ -137,6 +140,16 @@ export default function UploadFileDialog({
|
|
|
137
140
|
})
|
|
138
141
|
}
|
|
139
142
|
|
|
143
|
+
const handleSampleFileDownload = async () => {
|
|
144
|
+
try {
|
|
145
|
+
const res = await axios.get(sampleFileDownloadUrl)
|
|
146
|
+
|
|
147
|
+
buffertoCSV({ data: res.data, filename: `${dialogTitle}.csv` })
|
|
148
|
+
} catch (error) {
|
|
149
|
+
axiosErrorToast(error)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
140
153
|
useEffect(() => {
|
|
141
154
|
return () => {
|
|
142
155
|
setFile(null)
|
|
@@ -231,6 +244,15 @@ export default function UploadFileDialog({
|
|
|
231
244
|
</Button>
|
|
232
245
|
</a>
|
|
233
246
|
)}
|
|
247
|
+
{sampleFileDownloadUrl && (
|
|
248
|
+
<Button
|
|
249
|
+
variant="outlined"
|
|
250
|
+
fullWidth
|
|
251
|
+
onClick={handleSampleFileDownload}
|
|
252
|
+
>
|
|
253
|
+
Download Sample File
|
|
254
|
+
</Button>
|
|
255
|
+
)}
|
|
234
256
|
</StyledDialogContent>
|
|
235
257
|
</Dialog>
|
|
236
258
|
</>
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -76,7 +76,6 @@ const getInstitutionKey = () => {
|
|
|
76
76
|
} else {
|
|
77
77
|
return instituitionKey
|
|
78
78
|
}
|
|
79
|
-
return instituitionKey
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
function handleInstitutions(institutions) {
|
|
@@ -215,6 +214,7 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
|
215
214
|
s.username = res.data?.user?.username
|
|
216
215
|
s.user = res.data?.user
|
|
217
216
|
s.roles = res.data?.roles
|
|
217
|
+
s.globalUserId = res.data?.globalUserId
|
|
218
218
|
})
|
|
219
219
|
|
|
220
220
|
PermissionsStore.update((s) => {
|