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

Redirect to check-your-answers from reason page #931

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/return-requirements.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ async function submitReason (request, h) {
return h.view('return-requirements/reason.njk', pageData)
}

if (pageData.checkYourAnswersVisited) {
return h.redirect(`/system/return-requirements/${sessionId}/check-your-answers`)
}

return h.redirect(`/system/return-requirements/${sessionId}/setup`)
}

Expand Down
5 changes: 4 additions & 1 deletion app/services/return-requirements/submit-reason.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ async function go (sessionId, payload) {
if (!validationResult) {
await _save(session, payload)

return {}
return {
checkYourAnswersVisited: session.data.checkYourAnswersVisited
}
}

const formattedData = ReasonPresenter.go(session, payload)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select the reason for the return requirement',
...formattedData
Expand Down
6 changes: 5 additions & 1 deletion app/views/return-requirements/reason.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

{% block breadcrumbs %}
{# Back link #}
{% set backLink %}
/system/return-requirements/{{ id }}/{{ 'check-your-answers' if checkYourAnswersVisited else 'start-date' }}
{% endset %}

{{
govukBackLink({
text: 'Back',
href: '/system/return-requirements/' + id + '/start-date'
href: backLink
})
}}
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Submit Reason service', () => {

session = await SessionHelper.add({
data: {
checkYourAnswersVisited: false,
licence: {
id: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d',
currentVersionStartDate: '2023-01-01T00:00:00.000Z',
Expand Down Expand Up @@ -58,6 +59,7 @@ describe('Submit Reason service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
pageTitle: 'Select the reason for the return requirement',
licenceRef: '01/ABC'
}, { skip: ['id', 'error'] })
Expand All @@ -81,6 +83,7 @@ describe('Submit Reason service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
pageTitle: 'Select the reason for the return requirement',
licenceRef: '01/ABC'
}, { skip: ['id', 'error'] })
Expand Down
Loading