Skip to content

Commit

Permalink
Disable submission and editing once the user has clicked the submit b…
Browse files Browse the repository at this point in the history
…utton.
  • Loading branch information
ocielliottc committed Nov 5, 2024
1 parent a148613 commit 1fb363a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const FeedbackSubmitForm = ({
const { state, dispatch } = useContext(AppContext);
const csrf = selectCsrfToken(state);
const [isLoading, setIsLoading] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [isReviewing, setIsReviewing] = useState(reviewOnly);
const history = useHistory();
const [questionAnswerPairs, setQuestionAnswerPairs] = useState([]);
Expand Down Expand Up @@ -117,6 +118,7 @@ const FeedbackSubmitForm = ({
}

const onSubmitHandler = () => {
setIsSubmitting(true);
updateAllAnswersSubmit()
.then(res => {
for (let i = 0; i < res.length; ++i) {
Expand All @@ -135,9 +137,11 @@ const FeedbackSubmitForm = ({
})
.then(resTwo => {
if (resTwo === false) {
setIsSubmitting(false);
return;
}
updateRequestSubmit().then(res => {
setIsSubmitting(false);
if (res && res.payload && res.payload.data && !res.error) {
history.push(`/feedback/submit/confirmation/?request=${requestId}`);
} else {
Expand Down Expand Up @@ -225,7 +229,7 @@ const FeedbackSubmitForm = ({
<React.Fragment>
<Button
className={classes.coloredButton}
disabled={isLoading}
disabled={isLoading || isSubmitting}
onClick={() => setIsReviewing(false)}
variant="contained"
color="secondary"
Expand All @@ -234,7 +238,7 @@ const FeedbackSubmitForm = ({
</Button>
<Button
className={classes.button}
disabled={isLoading}
disabled={isLoading || isSubmitting}
onClick={onSubmitHandler}
variant="contained"
color="primary"
Expand Down

0 comments on commit 1fb363a

Please sign in to comment.