diff --git a/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx b/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx index f1c506089..dcbbff7bb 100644 --- a/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx +++ b/src/components/DataSubmissions/CreateDataSubmissionDialog.tsx @@ -212,7 +212,7 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { register, control, watch, - formState: { errors }, + formState: { isSubmitting, errors }, setValue, reset, } = useForm({ @@ -298,8 +298,8 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { dbGaPID, intention, dataType, - }: CreateSubmissionInput) => { - await createDataSubmission({ + }: CreateSubmissionInput) => + createDataSubmission({ variables: { studyID, dataCommons, @@ -310,6 +310,7 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { }, }) .then(() => { + reset(); setCreatingSubmission(false); setError(false); if (onCreate) { @@ -327,10 +328,9 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { setError(true); Logger.error("Error creating submission", e); }); - }; - const onSubmit: SubmitHandler = (data) => { - createSubmission(data); + const onSubmit: SubmitHandler = async (data) => { + await createSubmission(data); }; const validateEmpty = (value: string): string | null => @@ -563,6 +563,7 @@ const CreateDataSubmissionDialog: FC = ({ onCreate }) => { tabIndex={0} id="createSubmissionDialogCreateButton" form="create-submission-dialog-form" + disabled={isSubmitting} > Create