Skip to content

Commit

Permalink
fix form error message
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Nov 23, 2024
1 parent 9beaaa0 commit 1ab0f1c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/javascript/submission_form/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1247,9 +1247,13 @@ export default {
if (response.status === 422 || response.status === 500) {
const data = await response.json()
const i18nError = data.error ? this.t(data.error.replace(/\s+/g, '_').toLowerCase()) : ''
if (data.error) {
const i18nKey = data.error.replace(/\s+/g, '_').toLowerCase()
alert(i18nError !== data.error ? i18nError : (data.error || this.t('value_is_invalid')))
alert(this.t(i18nKey) !== i18nKey ? this.t(i18nKey) : data.error)
} else {
alert(this.t('value_is_invalid'))
}
return Promise.reject(new Error(data.error))
}
Expand Down

0 comments on commit 1ab0f1c

Please sign in to comment.