diff --git a/src/app/drivingLicence/controllers/check-your-details.js b/src/app/drivingLicence/controllers/check-your-details.js index 44b8572..d972bfe 100644 --- a/src/app/drivingLicence/controllers/check-your-details.js +++ b/src/app/drivingLicence/controllers/check-your-details.js @@ -4,6 +4,7 @@ const logger = require("hmpo-logger").get(); class CheckYourDetailsController extends BaseController { async saveValues(req, res, next) { try { + req.sessionModel.set("issuerDependent", req.sessionModel.get("licenceIssuer")); req.sessionModel.set("detailsNotConfirmed", undefined); const action = req.form.values.confirmDetails; diff --git a/src/app/drivingLicence/controllers/consent.js b/src/app/drivingLicence/controllers/consent.js new file mode 100644 index 0000000..f038a3e --- /dev/null +++ b/src/app/drivingLicence/controllers/consent.js @@ -0,0 +1,14 @@ +const BaseController = require("hmpo-form-wizard").Controller; +const logger = require("hmpo-logger").get(); + +class ConsentController extends BaseController { + async saveValues(req, res, next) { + try { + return next(); + } catch (err) { + logger.error("Error in consent controller - " + err); + return next(err); + } + } +} +module.exports = ConsentController; diff --git a/src/app/drivingLicence/controllers/consent.test.js b/src/app/drivingLicence/controllers/consent.test.js new file mode 100644 index 0000000..da25d17 --- /dev/null +++ b/src/app/drivingLicence/controllers/consent.test.js @@ -0,0 +1,26 @@ +const BaseController = require("hmpo-form-wizard").Controller; +const ConsentController = require("./consent"); + +describe("consent controller", () => { + const consentController = new ConsentController({ + route: "/test" + }); + + let req; + let res; + let next; + let sandbox; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + const setup = setupDefaultMocks(); + req = setup.req; + res = setup.res; + next = setup.next; + }); + afterEach(() => sandbox.restore()); + + it("should be an instance of BaseController", () => { + expect(consentController).to.be.an.instanceOf(BaseController); + }); +}); diff --git a/src/app/drivingLicence/controllers/validate.js b/src/app/drivingLicence/controllers/validate.js index f3d3b82..ec54f2f 100644 --- a/src/app/drivingLicence/controllers/validate.js +++ b/src/app/drivingLicence/controllers/validate.js @@ -10,6 +10,7 @@ const logger = require("hmpo-logger").get(); const { createPersonalDataHeaders } = require("@govuk-one-login/frontend-passthrough-headers"); +const { issuerDependent } = require("../fields"); class ValidateController extends BaseController { async saveValues(req, res, callback) { diff --git a/src/app/drivingLicence/steps.js b/src/app/drivingLicence/steps.js index d2981fe..b116b98 100644 --- a/src/app/drivingLicence/steps.js +++ b/src/app/drivingLicence/steps.js @@ -3,6 +3,7 @@ const root = require("./controllers/root"); const validate = require("./controllers/validate"); const licenceIssuer = require("./controllers/licence-issuer"); const checkYourDetails = require("./controllers/check-your-details"); +const consent = require("./controllers/consent"); module.exports = { "/": { @@ -28,9 +29,18 @@ module.exports = { value: true, next: "/prove-another-way" }, - "validate" + "consent" ] }, + "/consent":{ + controller: consent, + fields: [ + "issuerDependent", + "consentDVACheckbox", + "consentCheckbox" + ], + next: "validate" + }, "/licence-issuer": { controller: licenceIssuer, fields: ["licenceIssuer"], diff --git a/src/locales/cy/pages.yml b/src/locales/cy/pages.yml index e7cb4e5..67e2428 100644 --- a/src/locales/cy/pages.yml +++ b/src/locales/cy/pages.yml @@ -25,6 +25,12 @@ check-your-details: issueNumber: Issue number postcode: Postcode +consent: + title: We need to check your driving licence details + titleDVA: We need to check your driving licence details with the DVA + checkDVLA: We need to check the details you provided on your driving licence with the DVLA. + checkDVA: We need to check the details you provided on your driving licence with the DVA. + error: title: Mae'n ddrwg gennym, mae problem serviceNameRequired: false diff --git a/src/locales/en/pages.yml b/src/locales/en/pages.yml index 1777f63..28ea4ce 100644 --- a/src/locales/en/pages.yml +++ b/src/locales/en/pages.yml @@ -25,6 +25,12 @@ check-your-details: issueNumber: Issue number postcode: Postcode +consent: + title: We need to check your driving licence details + titleDVA: We need to check your driving licence details with the DVA + checkDVLA: We need to check the details you provided on your driving licence with the DVLA. + checkDVA: We need to check the details you provided on your driving licence with the DVA. + error: title: Sorry, there is a problem serviceNameRequired: false diff --git a/src/views/drivingLicence/consent.html b/src/views/drivingLicence/consent.html new file mode 100644 index 0000000..9f10a86 --- /dev/null +++ b/src/views/drivingLicence/consent.html @@ -0,0 +1,130 @@ +{% extends "base-form.njk" %} +{% set hmpoPageKey = "consent" %} +{% set hmpoH1Class = "govuk-heading-l" %} +{% from "hmpo-form/macro.njk" import hmpoForm %} +{% from "hmpo-checkboxes/macro.njk" import hmpoCheckboxes %} +{% from "hmpo-text/macro.njk" import hmpoText %} + +{% block mainContent %} + + {% call hmpoForm(ctx, { + attributes: { + onsubmit: 'window.disableFormSubmit()' + } + }) %} + + {% if (values.licenceIssuer == "DVA") %} + +

+ {{ translate("pages.consent.titleDVA") }} +

+

+ {{ translate("pages.consent.checkDVA") }} +

+

{{ translate("drivingLicence.consentDVA") }}

+ + {{ hmpoText(ctx, { + id: "issuerDependent", + type: "hidden", + legend: "", + default: "DVA" + }) }} + + {{ hmpoCheckboxes(ctx, { + id: "consentDVACheckbox", + hint: { + classes: "govuk-label" + } + }) }} + + {% endif %} + + {% if (values.licenceIssuer == "DVLA") %} + +

+ {{ translate("pages.consent.title") }} +

+

+ {{ translate("pages.consent.checkDVLA") }} +

+

{{ translate("drivingLicence.consentDVLA") }}

+ + {{ hmpoText(ctx, { + id: "issuerDependent", + type: "hidden", + legend: "", + default: "DVLA" + }) }} + + {{ hmpoCheckboxes(ctx, { + id: "consentCheckbox", + hint: { + classes: "govuk-label" + } + }) }} + + {% endif %} + + {{ hmpoSubmit(ctx, { + id: "continue", + text: translate("buttons.next") + }) }} + + {% endcall %} + +{% endblock %} + +{% block scripts %} + +{{ super ()}} + + + +{% endblock %} + +{% set footerNavItems = translate("govuk.footerNavItems") %} + +{% block footer %} +{{ govukFooter( footerNavItems ) }} +{% endblock %}