Skip to content

Commit

Permalink
Update files list after upload (#3580)
Browse files Browse the repository at this point in the history
* Update files list only after upload

* Show errror when file upload fails

* Return uploadfile as promise
  • Loading branch information
Ashesh3 authored Sep 16, 2022
1 parent 3d43afc commit 3514e14
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/Components/Patient/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,22 +466,29 @@ export const FileUpload = (props: FileUploadProps) => {
setUploadPercent(percentCompleted);
},
};
axios
.put(url, newFile, config)
.then(() => {
setUploadStarted(false);
// setUploadSuccess(true);
setFile(null);
setUploadFileName("");
setReload(!reload);
Notification.Success({
msg: "File Uploaded Successfully",
return new Promise<void>((resolve, reject) => {
axios
.put(url, newFile, config)
.then(() => {
setUploadStarted(false);
// setUploadSuccess(true);
setFile(null);
setUploadFileName("");
setReload(!reload);
Notification.Success({
msg: "File Uploaded Successfully",
});
setUploadFileNameError("");
resolve();
})
.catch((e) => {
Notification.Error({
msg: "Error Uploading File: " + e.message,
});
setUploadStarted(false);
reject();
});
setUploadFileNameError("");
})
.catch(() => {
setUploadStarted(false);
});
});
};

const validateFileUpload = () => {
Expand Down Expand Up @@ -519,11 +526,9 @@ export const FileUpload = (props: FileUploadProps) => {
.catch(() => {
setUploadStarted(false);
})
.then(fetchData(status).then(() => {}));

// setting the value of file name to empty
setUploadFileNameError("");
setUploadFileName("");
.then(() => {
fetchData(status);
});
};

const createAudioBlob = (createdBlob: Blob) => {
Expand Down

0 comments on commit 3514e14

Please sign in to comment.