()
| 15 | const [error, hasError] = React.useState<boolean>(false); |
| 16 | |
| 17 | function handleSubmit() { |
| 18 | if (fileInput.current && fileInput.current.files) { |
| 19 | const file = fileInput.current.files[0]; |
| 20 | if (!file) { |
| 21 | return; |
| 22 | } |
| 23 | const formData = new FormData(); |
| 24 | formData.append('file', file, file.name); |
| 25 | |
| 26 | setLoading(true); |
| 27 | upload(formData) |
| 28 | .then(() => { |
| 29 | alertSuccess({ message: 'Items successfully uploaded.' }); |
| 30 | fetchItems(); |
| 31 | setLoading(false); |
| 32 | hideModal(); |
| 33 | hasError(false); |
| 34 | }) |
| 35 | .catch(err => { |
| 36 | hasError(true); |
| 37 | setLoading(false); |
| 38 | }); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const errorMsg = () => ( |
| 43 | <Alert type="error" |
nothing calls this directly
no test coverage detected