Open TylerHendrickson opened 1 year ago
cc @caitlinwinner for input on how errors should behave in the UI.
@agn-dsgn
CC: @caitlinwinner @TylerHendrickson Also recommended for: #1376
Design recommendations My recommendation from the design side is to throw an error immediately upon user input, BEFORE they hit submit.
We should use the current pattern, wherein if any input field in the modal has an error, the "OK" (save) button is disabled.
Whenever possible we should strive to prevent user error as early as possible to prevent extra time and effort on the user's part.
Here's how that would look (Imagine each input field is improperly filled out)
Text
An agency with that name already exists
An agency with that code already exists
In ARPA, we already throw an error post-submission. While not ideal this could be a backup solution for Grants Finder as well. We could use the alert pattern within the modal in this case.
Also note, if we must throw other errors with these inputs, assume we'll throw them first, letting users address each sequentially.
Error order of operations:
@TylerHendrickson are the above mocks sufficient?
Description: This issue is similar to #1376, but relates to scenarios where users are attempting to update an existing agency rather than create a new one. Although the queries issued to Postgres are different, the same unique constraint violation errors are thrown (depending on whether the request attempted to set the agencies name or code to a non-unique value, the
UPDATE
query violates theagencies_tenant_id_name_unique
oragencies_tenant_id_code_unique
unique constraints, respectively). As with #1376, the UI does not provide any indication that a problem occurred, although in this case the modal closes upon form submission, making the error even harder to detect for the end-user.Steps to reproduce:
PUT /api/organizations/:organizationId/agencies/name/:agency
request issued upon form has a status code of 500.PUT /api/organizations/:organizationId/agencies/code/:agency
request issued upon form has a status code of 500.Impacts:
Desired behavior:
Implementation details:
PUT /api/organizations/:organizationId/agencies/name/:agency
andPUT /api/organizations/:organizationId/agencies/code/:agency
API endpoints to catch unique constraint violation errors encountered when attempting to persist a new agency to the DB, and handle those errors by issuing a 400 response that conveys the nature of the problem.