-
Notifications
You must be signed in to change notification settings - Fork 0
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
Move rtn req. routes and session handling #597
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f7cefd2
Move rtn req. routes and session handling example
Cruikshanks cdf62b0
Merge branch 'main' into lick-it-and-stick-it
robertparkinson e4974af
create return requirements section
robertparkinson 685e529
reorder routes and contollers to match the flow of the pages and use …
robertparkinson 33e1c20
Merge branch 'main' into lick-it-and-stick-it
robertparkinson 28f25af
extract id to make function different for sonarcloud until we have ac…
robertparkinson 4a036e4
merge from main
robertparkinson bcb5ee5
remove conosle.log
robertparkinson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,164 @@ | ||
'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) { | ||
const { sessionId } = request.params | ||
|
||
const session = await SessionModel.query().findById(sessionId) | ||
|
||
return h.view('return-requirements/requirements-approved.njk', { | ||
activeNavBar: 'search', | ||
...session | ||
}) | ||
} | ||
|
||
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-returns-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`) | ||
} | ||
|
||
module.exports = { | ||
addANote, | ||
noReturnsCheckYourAnswers, | ||
noReturnsRequired, | ||
reasonNewRequirements, | ||
requirementsApproved, | ||
returnsCheckYourAnswers, | ||
returnsHowDoYouWant, | ||
saveNoReturnsCheckYourAnswers, | ||
saveNoReturnsRequired, | ||
saveNote, | ||
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 | ||
---|---|---|---|---|
|
@@ -47,6 +47,7 @@ const AuthPlugin = { | |||
}, | ||||
redirectTo: '/signin', | ||||
validate: async (_request, session) => { | ||||
console.log('🚀 ~ file: auth.plugin.js:50 ~ validate: ~ session:', session) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doh! Something I should have spotted the first time around.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weird that it's showing up on my PR.. it's not something I added. but i've removed it now |
||||
return AuthService.go(session.userId) | ||||
} | ||||
}) | ||||
|
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sonarcloud is complaining about this function being the same as
saveNote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put in a small change to make it pass.