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

Return to Check Your Answers after making a change #959

Merged
merged 5 commits into from
May 1, 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
32 changes: 32 additions & 0 deletions app/controllers/return-requirements.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ async function submitAbstractionPeriod (request, h) {
return h.view('return-requirements/abstraction-period.njk', pageData)
}

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

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

Expand All @@ -229,6 +233,10 @@ async function submitAgreementsExceptions (request, h) {
return h.view('return-requirements/agreements-exceptions.njk', pageData)
}

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

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

Expand All @@ -254,6 +262,10 @@ async function submitFrequencyCollected (request, h) {
return h.view('return-requirements/frequency-collected.njk', pageData)
}

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

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

Expand All @@ -266,6 +278,10 @@ async function submitFrequencyReported (request, h) {
return h.view('return-requirements/frequency-reported.njk', pageData)
}

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

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

Expand All @@ -290,6 +306,10 @@ async function submitPoints (request, h) {
return h.view('return-requirements/points.njk', pageData)
}

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

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

Expand All @@ -302,6 +322,10 @@ async function submitPurpose (request, h) {
return h.view('return-requirements/purpose.njk', pageData)
}

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

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

Expand Down Expand Up @@ -330,6 +354,10 @@ async function submitReturnsCycle (request, h) {
return h.view('return-requirements/returns-cycle.njk', pageData)
}

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

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

Expand All @@ -354,6 +382,10 @@ async function submitSiteDescription (request, h) {
return h.view('return-requirements/site-description.njk', pageData)
}

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

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

Expand Down
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 submittedSessionData = _submittedSessionData(session, payload)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Enter the abstraction period for the requirements for returns',
...submittedSessionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ async function go (sessionId, payload) {
if (!validationResult) {
await _save(session, payload)

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

const formattedData = AgreementsExceptionsPresenter.go(session, payload)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select agreements and exceptions for the requirements for returns',
...formattedData
Expand Down
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 = FrequencyCollectedPresenter.go(session)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select how often readings or volumes are collected',
...formattedData
Expand Down
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 = FrequencyReportedPresenter.go(session)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select how often readings or volumes are reported',
...formattedData
Expand Down
5 changes: 4 additions & 1 deletion app/services/return-requirements/submit-points.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ async function go (sessionId, payload) {
if (!validationResult) {
await _save(session, payload)

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

const pointsData = await FetchPointsService.go(session.data.licence.id)
const formattedData = PointsPresenter.go(session, pointsData)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select the points for the requirements for returns',
...formattedData
Expand Down
5 changes: 4 additions & 1 deletion app/services/return-requirements/submit-purpose.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ async function go (sessionId, payload) {
if (!validationResult) {
await _save(session, payload)

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

const purposesData = await FetchPurposesService.go(session.data.licence.id)
const formattedData = PurposePresenter.go(session, purposesData)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select the purpose for the requirements for returns',
...formattedData
Expand Down
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 = ReturnsCyclePresenter.go(session)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Select the returns cycle for the requirements for returns',
...formattedData
Expand Down
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 submittedSessionData = _submittedSessionData(session, payload)

return {
activeNavBar: 'search',
checkYourAnswersVisited: session.data.checkYourAnswersVisited,
error: validationResult,
pageTitle: 'Enter a site description for the requirements for returns',
...submittedSessionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Submit Abstraction Period 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 @@ -60,10 +61,12 @@ describe('Submit Abstraction Period service', () => {
})
})

it('returns an empty object (no page data needed for a redirect)', async () => {
it('returns the checkYourAnswersVisited property (no page data needed for a redirect)', async () => {
const result = await SubmitAbstractionPeriodService.go(session.id, payload)

expect(result).to.equal({})
expect(result).to.equal({
checkYourAnswersVisited: false
})
})
})

Expand All @@ -85,6 +88,7 @@ describe('Submit Abstraction Period service', () => {
expect(result).to.equal({
abstractionPeriod: null,
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down Expand Up @@ -126,6 +130,7 @@ describe('Submit Abstraction Period service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down Expand Up @@ -173,6 +178,7 @@ describe('Submit Abstraction Period service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down Expand Up @@ -220,6 +226,7 @@ describe('Submit Abstraction Period service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down Expand Up @@ -267,6 +274,7 @@ describe('Submit Abstraction Period service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down Expand Up @@ -314,6 +322,7 @@ describe('Submit Abstraction Period service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Enter the abstraction period for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Submit Agreements and Exceptions 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 @@ -60,10 +61,12 @@ describe('Submit Agreements and Exceptions service', () => {
])
})

it('returns an empty object (no page data needed for a redirect)', async () => {
it('returns the checkYourAnswersVisited property (no page data needed for a redirect)', async () => {
const result = await SubmitAgreementsExceptionsService.go(session.id, payload)

expect(result).to.equal({})
expect(result).to.equal({
checkYourAnswersVisited: false
})
})
})
})
Expand All @@ -85,6 +88,7 @@ describe('Submit Agreements and Exceptions service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
error: null,
pageTitle: 'Select agreements and exceptions for the requirements for returns',
id: 'aeb46f58-3431-42af-8724-361a7779becf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Submit Frequency Collected 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 @@ -52,10 +53,12 @@ describe('Submit Frequency Collected service', () => {
expect(refreshedSession.data.frequencyCollected).to.equal('weekly')
})

it('returns an empty object (no page data needed for a redirect)', async () => {
it('returns the checkYourAnswersVisited property (no page data needed for a redirect)', async () => {
const result = await SubmitFrequencyCollectedService.go(session.id, payload)

expect(result).to.equal({})
expect(result).to.equal({
checkYourAnswersVisited: false
})
})
})

Expand All @@ -76,6 +79,7 @@ describe('Submit Frequency Collected service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d',
licenceRef: '01/ABC',
pageTitle: 'Select how often readings or volumes are collected',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Submit Frequency Reported 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 @@ -52,10 +53,12 @@ describe('Submit Frequency Reported service', () => {
expect(refreshedSession.data.frequencyReported).to.equal('weekly')
})

it('returns an empty object (no page data needed for a redirect)', async () => {
it('returns the checkYourAnswersVisited property (no page data needed for a redirect)', async () => {
const result = await SubmitFrequencyReportedService.go(session.id, payload)

expect(result).to.equal({})
expect(result).to.equal({
checkYourAnswersVisited: false
})
})
})

Expand All @@ -76,6 +79,7 @@ describe('Submit Frequency Reported service', () => {

expect(result).to.equal({
activeNavBar: 'search',
checkYourAnswersVisited: false,
licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d',
licenceRef: '01/ABC',
pageTitle: 'Select how often readings or volumes are reported',
Expand Down
Loading
Loading