@@ -78,6 +78,7 @@ const FeedbackSubmitForm = ({
7878 const { state, dispatch } = useContext ( AppContext ) ;
7979 const csrf = selectCsrfToken ( state ) ;
8080 const [ isLoading , setIsLoading ] = useState ( false ) ;
81+ const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
8182 const [ isReviewing , setIsReviewing ] = useState ( reviewOnly ) ;
8283 const history = useHistory ( ) ;
8384 const [ questionAnswerPairs , setQuestionAnswerPairs ] = useState ( [ ] ) ;
@@ -117,6 +118,7 @@ const FeedbackSubmitForm = ({
117118 }
118119
119120 const onSubmitHandler = ( ) => {
121+ setIsSubmitting ( true ) ;
120122 updateAllAnswersSubmit ( )
121123 . then ( res => {
122124 for ( let i = 0 ; i < res . length ; ++ i ) {
@@ -135,9 +137,11 @@ const FeedbackSubmitForm = ({
135137 } )
136138 . then ( resTwo => {
137139 if ( resTwo === false ) {
140+ setIsSubmitting ( false ) ;
138141 return ;
139142 }
140143 updateRequestSubmit ( ) . then ( res => {
144+ setIsSubmitting ( false ) ;
141145 if ( res && res . payload && res . payload . data && ! res . error ) {
142146 history . push ( `/feedback/submit/confirmation/?request=${ requestId } ` ) ;
143147 } else {
@@ -225,7 +229,7 @@ const FeedbackSubmitForm = ({
225229 < React . Fragment >
226230 < Button
227231 className = { classes . coloredButton }
228- disabled = { isLoading }
232+ disabled = { isLoading || isSubmitting }
229233 onClick = { ( ) => setIsReviewing ( false ) }
230234 variant = "contained"
231235 color = "secondary"
@@ -234,7 +238,7 @@ const FeedbackSubmitForm = ({
234238 </ Button >
235239 < Button
236240 className = { classes . button }
237- disabled = { isLoading }
241+ disabled = { isLoading || isSubmitting }
238242 onClick = { onSubmitHandler }
239243 variant = "contained"
240244 color = "primary"
0 commit comments