Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update MyInfo field count correctly, show correct error #1738

Merged
merged 2 commits into from
Apr 27, 2021

Conversation

mantariksh
Copy link
Contributor

Problem

  1. When user attempts to save more MyInfo fields than is allowed, a generic error message shows in the Toastr, rather than the specific one returned by the backend.
  2. On the build tab, MyInfo field count does not update upon creation of MyInfo field.

Solution

Fixing error message

The initial error message was:
image

This was fixed by accessing error.response.status rather than error.status, since error is now an AxiosError.

The error message then changed to this:
Screenshot 2021-04-27 at 10 54 16 AM

This was because we return a 422 when an error occurs while editing fields, and the switch case handles 422s by attempting to access error.data.message. This was fixed by accessing error.response.data.message instead.

This finally fixed the error message:
Screenshot 2021-04-27 at 10 54 55 AM

Updating MyInfo field count

This was fixed by assigning to $scope.myform.form_fields instead of pushing to the array, which triggers the AngularJS digest cycle correctly.

Error messages were showing up incorrectly due to incorrect accessing
of keys in the error object. The fix was to access the correct keys.
This triggers the AngularJS digest cycle correctly, which updates the
count of MyInfo fields correctly.
@mantariksh mantariksh requested a review from karrui April 27, 2021 03:04
Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@karrui karrui mentioned this pull request Apr 27, 2021
@mantariksh mantariksh merged commit 71410c9 into develop Apr 27, 2021
@mantariksh mantariksh deleted the fix/create-myinfo-field branch May 18, 2021 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants