Skip to content

Commit

Permalink
Merge branch 'main' into move-send-transactions-to-route-with-refacto…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
Cruikshanks authored Feb 20, 2024
2 parents 234a9a3 + 7cf1a32 commit d12f688
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/controllers/return-requirements.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ async function checkYourAnswers (request, h) {
})
}

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

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

return h.view('return-requirements/existing.njk', {
activeNavBar: 'search',
pageTitle: 'Select an existing return requirement from',
...session
})
}

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

Expand Down Expand Up @@ -213,6 +225,12 @@ async function submitCheckYourAnswers (request, h) {
return h.redirect(`/system/return-requirements/${licenceId}/approved`)
}

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

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

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

Expand Down Expand Up @@ -307,6 +325,7 @@ module.exports = {
agreementsExceptions,
approved,
checkYourAnswers,
existing,
frequencyCollected,
frequencyReported,
noReturnsRequired,
Expand All @@ -321,6 +340,7 @@ module.exports = {
submitAddNote,
submitAgreementsExceptions,
submitCheckYourAnswers,
submitExisting,
submitFrequencyCollected,
submitFrequencyReported,
submitNoReturnsRequired,
Expand Down
26 changes: 26 additions & 0 deletions app/routes/return-requirement.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ const routes = [
description: 'Submit check your answers'
}
},
{
method: 'GET',
path: '/return-requirements/{sessionId}/existing',
handler: ReturnRequirementsController.existing,
options: {
auth: {
access: {
scope: ['billing']
}
},
description: 'Select an existing return requirement from'
}
},
{
method: 'POST',
path: '/return-requirements/{sessionId}/existing',
handler: ReturnRequirementsController.submitExisting,
options: {
auth: {
access: {
scope: ['billing']
}
},
description: 'Submit an existing return requirement from'
}
},
{
method: 'GET',
path: '/return-requirements/{sessionId}/frequency-collected',
Expand Down
28 changes: 28 additions & 0 deletions app/views/return-requirements/existing.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends 'layout.njk' %}
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
{% from "govuk/components/button/macro.njk" import govukButton %}

{% set rootLink = "/system/return-requirements/" + id %}

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

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

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

describe('GET /return-requirements/{sessionId}/existing', () => {
describe('when the request succeeds', () => {
it('returns the page successfully', async () => {
const response = await server.inject(_options('existing'))

expect(response.statusCode).to.equal(200)
expect(response.payload).to.contain('Select an existing return requirement from')
})
})
})

describe('GET /return-requirements/{sessionId}/frequency-collected', () => {
describe('when the request succeeds', () => {
it('returns the page successfully', async () => {
Expand Down

0 comments on commit d12f688

Please sign in to comment.