Skip to content

Commit

Permalink
fix: update MyInfo field count correctly, show correct error (#1738)
Browse files Browse the repository at this point in the history
* fix: show correct error message

Error messages were showing up incorrectly due to incorrect accessing
of keys in the error object. The fix was to access the correct keys.

* fix: change push to assignment

This triggers the AngularJS digest cycle correctly, which updates the
count of MyInfo fields correctly.
  • Loading branch information
mantariksh authored Apr 27, 2021
1 parent 2c5b87c commit 71410c9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ function AdminFormController(
return
}
let errorMessage
switch (error.status) {
const status = get(error, 'response.status') || get(error, 'status')
switch (status) {
case StatusCodes.CONFLICT:
case StatusCodes.BAD_REQUEST:
errorMessage =
Expand All @@ -155,7 +156,7 @@ function AdminFormController(
// Validation can fail for many reasons, so return more specific message
errorMessage = get(
error,
'data.message',
'response.data.message',
'Your changes contain invalid input.',
)
break
Expand Down Expand Up @@ -190,7 +191,10 @@ function AdminFormController(
.when(AdminFormService.createSingleFormField($scope.myform._id, body))
.then((updatedFormField) => {
// insert created field into form
$scope.myform.form_fields.push(updatedFormField)
$scope.myform.form_fields = [
...$scope.myform.form_fields,
updatedFormField,
]
})
.catch(handleUpdateError)
}
Expand Down

0 comments on commit 71410c9

Please sign in to comment.