-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
614 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
'use strict' | ||
|
||
/** | ||
* Controller for /return-requirement endpoints | ||
* @module ReturnRequirementsController | ||
*/ | ||
|
||
const SessionModel = require('../models/session.model.js') | ||
|
||
async function selectReturnStartDate (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/select-return-start-date.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveReturnStartDate (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.redirect(`/system/return-requirements/${session.id}/reason`) | ||
} | ||
|
||
async function reasonNewRequirements (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/reason.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveReasonNewRequirements (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.redirect(`/system/return-requirements/${session.id}/returns-how-do-you-want`) | ||
} | ||
|
||
async function returnsHowDoYouWant (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/returns-how-do-you-want.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveReturnsHowDoYouWant (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.redirect(`/system/return-requirements/${session.id}/returns-check-your-answers`) | ||
} | ||
|
||
async function returnsCheckYourAnswers (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/returns-check-your-answers.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveReturnsCheckYourAnswers (request, h) { | ||
return h.redirect('/system/return-requirements/requirements-approved') | ||
} | ||
|
||
async function requirementsApproved (request, h) { | ||
return h.view('return-requirements/requirements-approved.njk', { | ||
activeNavBar: 'search' | ||
}) | ||
} | ||
|
||
async function noReturnsRequired (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/no-returns-required.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveNoReturnsRequired (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.redirect(`/system/return-requirements/${session.id}/no-return-check-your-answers`) | ||
} | ||
|
||
async function noReturnsCheckYourAnswers (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/no-return-check-your-answers.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveNoReturnsCheckYourAnswers (request, h) { | ||
return h.redirect('/system/return-requirements/requirements-approved') | ||
} | ||
|
||
async function addANote (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/add-a-note.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
async function saveNote (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
const { id } = session | ||
|
||
return h.redirect(`/system/return-requirements/${id}/returns-check-your-answers`) | ||
} | ||
|
||
async function selectPurpose (request, h) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
const { id } = session | ||
|
||
return h.redirect(`/system/return-requirements/${id}/purpose`) | ||
} | ||
|
||
module.exports = { | ||
addANote, | ||
noReturnsCheckYourAnswers, | ||
noReturnsRequired, | ||
reasonNewRequirements, | ||
requirementsApproved, | ||
returnsCheckYourAnswers, | ||
returnsHowDoYouWant, | ||
saveNoReturnsCheckYourAnswers, | ||
saveNoReturnsRequired, | ||
saveNote, | ||
selectPurpose, | ||
saveReasonNewRequirements, | ||
saveReturnsCheckYourAnswers, | ||
saveReturnsHowDoYouWant, | ||
saveReturnStartDate, | ||
selectReturnStartDate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
'use strict' | ||
|
||
const ReturnRequirementsController = require('../controllers/return-requirements.controller.js') | ||
|
||
const routes = [ | ||
{ | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/select-return-start-date', | ||
handler: ReturnRequirementsController.selectReturnStartDate, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Select the start date of the return' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/select-return-start-date', | ||
handler: ReturnRequirementsController.saveReturnStartDate, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Select the start date of the return' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/reason', | ||
handler: ReturnRequirementsController.reasonNewRequirements, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Reason page' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/reason', | ||
handler: ReturnRequirementsController.saveReasonNewRequirements, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Reason page' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/returns-how-do-you-want', | ||
handler: ReturnRequirementsController.returnsHowDoYouWant, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns required - create How do you want to set up the requirements' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/returns-how-do-you-want', | ||
handler: ReturnRequirementsController.saveReturnsHowDoYouWant, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns required - create How do you want to set up the requirements' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/returns-check-your-answers', | ||
handler: ReturnRequirementsController.returnsCheckYourAnswers, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns check your answers page' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/returns-check-your-answers', | ||
handler: ReturnRequirementsController.saveReturnsCheckYourAnswers, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns check your answers page' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/requirements-approved', | ||
handler: ReturnRequirementsController.requirementsApproved, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns requirements approved' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/no-returns-required', | ||
handler: ReturnRequirementsController.noReturnsRequired, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Show no returns required page' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/no-returns-required', | ||
handler: ReturnRequirementsController.saveNoReturnsRequired, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Save no returns required option' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/no-return-check-your-answers', | ||
handler: ReturnRequirementsController.noReturnsCheckYourAnswers, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'No return check your answers page' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/no-return-check-your-answers', | ||
handler: ReturnRequirementsController.saveNoReturnsCheckYourAnswers, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'No return check your answers page' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/add-a-note', | ||
handler: ReturnRequirementsController.addANote, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Returns add a note page' | ||
} | ||
}, { | ||
method: 'POST', | ||
path: '/return-requirements/{sessionId}/add-a-note', | ||
handler: ReturnRequirementsController.saveNote, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Save note' | ||
} | ||
}, { | ||
method: 'GET', | ||
path: '/return-requirements/{sessionId}/purpose', | ||
handler: ReturnRequirementsController.selectPurpose, | ||
options: { | ||
auth: { | ||
access: { | ||
scope: ['billing'] | ||
} | ||
}, | ||
description: 'Select prupose for returns requirement page' | ||
} | ||
} | ||
] | ||
|
||
module.exports = routes |
Oops, something went wrong.