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

Select returns cycle for returns set up #611

Merged
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
12 changes: 12 additions & 0 deletions app/controllers/return-requirements.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ async function saveNote (request, h) {
return h.redirect(`/system/return-requirements/${id}/returns-check-your-answers`)
}

async function saveReturnsCycle (request, h) {
const { sessionId } = request.params

const session = await SessionModel.query().findById(sessionId)

return h.view('return-requirements/returns-cycle.njk', {
activeNavBar: 'search',
...session
})
}

async function returnsFrequency (request, h) {
const { sessionId } = request.params

Expand Down Expand Up @@ -201,6 +212,7 @@ module.exports = {
selectPurpose,
saveReasonNewRequirements,
saveReturnsCheckYourAnswers,
saveReturnsCycle,
saveReturnsHowDoYouWant,
saveReturnStartDate,
selectReturnStartDate
Expand Down
12 changes: 12 additions & 0 deletions app/routes/return-requirement.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ const routes = [
},
description: 'Save note'
}
}, {
method: 'GET',
path: '/return-requirements/{sessionId}/returns-cycle',
handler: ReturnRequirementsController.saveReturnsCycle,
options: {
auth: {
access: {
scope: ['billing']
}
},
description: 'Returns Select the returns cycle page'
}
}, {
method: 'GET',
path: '/return-requirements/{sessionId}/frequency',
Expand Down
29 changes: 29 additions & 0 deletions app/views/return-requirements/returns-cycle.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends 'layout.njk' %}
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
{% from "govuk/components/button/macro.njk" import govukButton %}

{% set title = "Select the returns cycle for the return requirement" %}
{% set rootLink = "/system/return-requirements/" + id %}

{% block breadcrumbs %}
{# Back link #}
{{
govukBackLink({
text: 'Back',
href: rootLink + "/time-limit"
})
}}
{% endblock %}

{% block content %}
{# Main heading #}
<div class="govuk-body">
<h1 class="govuk-heading-xl govuk-!-margin-bottom-3">{{ title }}</h1>
</div>

<form method="post">
<div class="govuk-body">
{{ govukButton({ text: "Continue" }) }}
</div>
</form>
{% endblock %}
20 changes: 20 additions & 0 deletions test/controllers/return-requirements.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ describe('Return requirements controller', () => {
})
})

describe('GET /return-requirements/{sessionId}/returns-cycle', () => {
const options = {
method: 'GET',
url: '/return-requirements/64924759-8142-4a08-9d1e-1e902cd9d316/returns-cycle',
auth: {
strategy: 'session',
credentials: { scope: ['billing'] }
}
}

describe('when the request succeeds', () => {
it('returns the page successfully', async () => {
const response = await server.inject(options)

expect(response.statusCode).to.equal(200)
expect(response.payload).to.contain('Select the returns cycle for the return requirement')
})
})
})

describe('GET /return-requirements/{sessionId}/frequency', () => {
const options = {
method: 'GET',
Expand Down
Loading