diff --git a/awx/ui_next/src/screens/Template/Survey/SurveyQuestionAdd.jsx b/awx/ui_next/src/screens/Template/Survey/SurveyQuestionAdd.jsx index 9889f824cf..009c295bf7 100644 --- a/awx/ui_next/src/screens/Template/Survey/SurveyQuestionAdd.jsx +++ b/awx/ui_next/src/screens/Template/Survey/SurveyQuestionAdd.jsx @@ -9,15 +9,15 @@ export default function SurveyQuestionAdd({ survey, updateSurvey }) { const match = useRouteMatch(); const handleSubmit = async question => { - if (survey.spec?.some(q => q.variable === question.variable)) { - setFormError( - new Error( - `Survey already contains a question with variable named “${question.variable}”` - ) - ); - return; - } try { + if (survey.spec?.some(q => q.variable === question.variable)) { + setFormError( + new Error( + `Survey already contains a question with variable named “${question.variable}”` + ) + ); + return; + } const newSpec = survey.spec ? survey.spec.concat(question) : [question]; await updateSurvey(newSpec); history.push(match.url.replace('/add', '')); diff --git a/awx/ui_next/src/screens/Template/Survey/SurveyQuestionEdit.jsx b/awx/ui_next/src/screens/Template/Survey/SurveyQuestionEdit.jsx index cb9dac0a58..9c6ac6193a 100644 --- a/awx/ui_next/src/screens/Template/Survey/SurveyQuestionEdit.jsx +++ b/awx/ui_next/src/screens/Template/Survey/SurveyQuestionEdit.jsx @@ -21,19 +21,18 @@ export default function SurveyQuestionEdit({ survey, updateSurvey }) { }; const handleSubmit = async formData => { - if ( - formData.variable !== question.variable && - survey.spec.find(q => q.variable === formData.variable) - ) { - debugger; - setFormError( - new Error( - `Survey already contains a question with variable named “${formData.variable}”` - ) - ); - return; - } try { + if ( + formData.variable !== question.variable && + survey.spec.find(q => q.variable === formData.variable) + ) { + setFormError( + new Error( + `Survey already contains a question with variable named “${formData.variable}”` + ) + ); + return; + } const questionIndex = survey.spec.findIndex( q => q.variable === match.params.variable );