@campxdev/shared 1.11.45 → 1.11.47
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
|
@@ -4,7 +4,7 @@ import { toast } from 'react-toastify'
|
|
|
4
4
|
import axios from '../../config/axios'
|
|
5
5
|
import { UploadButtonProps } from './types'
|
|
6
6
|
|
|
7
|
-
const getAccept = (type: UploadButtonProps['type']) => {
|
|
7
|
+
export const getAccept = (type: UploadButtonProps['type']) => {
|
|
8
8
|
switch (type) {
|
|
9
9
|
case 'file':
|
|
10
10
|
return '.xlsx,.xls,.doc, .docx,.ppt, .pptx,.txt,.pdf'
|
|
@@ -14,6 +14,8 @@ const getAccept = (type: UploadButtonProps['type']) => {
|
|
|
14
14
|
return 'video/*'
|
|
15
15
|
case 'audio':
|
|
16
16
|
return 'audio/*'
|
|
17
|
+
case 'excel':
|
|
18
|
+
return '.xlsx,.xls,.csv'
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react'
|
|
2
2
|
|
|
3
3
|
interface Media {
|
|
4
|
-
type: 'image' | 'video' | 'audio' | 'file'
|
|
4
|
+
type: 'image' | 'video' | 'audio' | 'file' | 'excel'
|
|
5
5
|
url: string
|
|
6
6
|
key: string
|
|
7
7
|
fileName?: string
|
|
@@ -9,7 +9,7 @@ interface Media {
|
|
|
9
9
|
mediaObject?: any
|
|
10
10
|
}
|
|
11
11
|
interface UploadButtonProps {
|
|
12
|
-
type: 'file' | 'image' | 'video' | 'audio'
|
|
12
|
+
type: 'file' | 'image' | 'video' | 'audio' | 'excel'
|
|
13
13
|
onChange: (res: Media) => void
|
|
14
14
|
uploadUrl: string
|
|
15
15
|
onSuccess?: () => void
|
|
@@ -18,6 +18,8 @@ import axios from '../../config/axios'
|
|
|
18
18
|
import { buffertoCSV } from '../../utils'
|
|
19
19
|
import { useErrorModal } from '../ErrorModalWrapper/ErrorModalWrapper'
|
|
20
20
|
import { DeleteButton, EditButton } from '../IconButtons'
|
|
21
|
+
import { getAccept } from '../UploadButton/UploadButton'
|
|
22
|
+
import { UploadButtonProps } from '../UploadButton/types'
|
|
21
23
|
const animatedImage = require('./AnimatedUploadFile.gif')
|
|
22
24
|
|
|
23
25
|
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
@@ -83,6 +85,7 @@ interface UploadFileDialogProps {
|
|
|
83
85
|
refetchFn?: (res: any) => void
|
|
84
86
|
onUpload?: () => void
|
|
85
87
|
postBody?: { [key: string]: string }
|
|
88
|
+
type?: UploadButtonProps['type']
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
export default function UploadFileDialog({
|
|
@@ -97,6 +100,7 @@ export default function UploadFileDialog({
|
|
|
97
100
|
sampleFileDownloadUrl,
|
|
98
101
|
postBody = {},
|
|
99
102
|
onUpload,
|
|
103
|
+
type = 'excel',
|
|
100
104
|
}: UploadFileDialogProps) {
|
|
101
105
|
const inputRef: any = useRef(null)
|
|
102
106
|
const [loading, setLoading] = useState(false)
|
|
@@ -138,6 +142,7 @@ export default function UploadFileDialog({
|
|
|
138
142
|
setFile(null)
|
|
139
143
|
})
|
|
140
144
|
.catch((err) => {
|
|
145
|
+
// eslint-disable-next-line no-console
|
|
141
146
|
console.log(err)
|
|
142
147
|
setLoading(false)
|
|
143
148
|
// axiosErrorToast(err)
|
|
@@ -199,7 +204,8 @@ export default function UploadFileDialog({
|
|
|
199
204
|
<input
|
|
200
205
|
onChange={handleImageChange}
|
|
201
206
|
hidden
|
|
202
|
-
type
|
|
207
|
+
accept={getAccept(type)}
|
|
208
|
+
type={'file'}
|
|
203
209
|
ref={inputRef}
|
|
204
210
|
/>
|
|
205
211
|
<StyledChooseFileButton
|