Map 1745 UOF bug users unable to access incident details page #743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MAP-1745
This code change fixes the scenario where the /incident-details page will not load if an offender is currently in a transfer or has left prison. This is signified by the offenders agencyId being TRN or OUT.
In such cases, loading of incident-details fails (and throws a 400 error) because TRN and OUT are not actual prisons and getting their internal locations, which are required by the select drop-down on the page, would return an error.
With the new code, when a user selects /incident-details, a check of the agencyId is done. If it's either TRN or OUT then we redirect to the change prison page. The /change-prison endpoint has been renamed to /prison-of-incident because the user's first action may not have been to change prison straight away but rather it's an action that's forced on them.
In the previous code, selecting the 'Change' link in /incident-details page saves any user input and calls draftReportService.process which either updates an existing report or creates a new one. This is triggered via frontend javascript that acts on components with the 'js-submitLink' html class. Because the frontend javascript trigger is now being circumvented by the immediate redirect to /prison-of-incident, the draftReportService.process is called in the submit of /prison-of-incident.
Have used flash to pass any user inputs to /prison-of-incident