WIP ACRS-186: Custom routing for aggregate 'are you referring a...' pages DO NOT MERGE #136
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.
What?
Add conditional routing to
save-form-session.js
behaviour for aggregate intro questions such as 'Are you referring a parent?'.There are 6 aggregates this caters for: 'Parent', 'Siblings' ('brother or sister'), 'Partner', 'Children', 'Additional family' and 'Family in the UK'.
Added an additional check when attempting to move beyond the summary to make sure the user had not removed all their referred people (have to refer at least one from any referral aggregate). This redirects accordingly to
/no-family-referred
Also fixed the reset behaviour for 2 aggregates (partner, family in UK) that should remove aggregated data when 'no' is chosen after people had already been "referred" in that field.
Why?
These are yes/no questions whose condition related to overall form progress and other aggregate form input becomes conditional. For example the onwards navigation is different if the user has come to the page from a main summary 'check your answers' page or whether there was already aggregated data in session or not.
How?
Added a switch statement in save-form-session behaviour to pick up on the current route and then check onward route if it is in the correct cohort for custom routing. If a condition is satisfied, then redirect before HOF manages the next page on its own.
Added two new functions to check the current session and form state and deliver the correct route to nav to. Mainly to keep the body of the exported behaviour tidy.
Testing?
Tested locally. Could do with branch testing before merge to master.
Check list
here is an example commit