Skip to content

Commit

Permalink
LIME-1328 consent screen added
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelRobGDS committed Nov 8, 2024
1 parent 1838c76 commit df9de76
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/drivingLicence/controllers/check-your-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 14 additions & 0 deletions src/app/drivingLicence/controllers/consent.js
Original file line number Diff line number Diff line change
@@ -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;
26 changes: 26 additions & 0 deletions src/app/drivingLicence/controllers/consent.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
1 change: 1 addition & 0 deletions src/app/drivingLicence/controllers/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion src/app/drivingLicence/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
"/": {
Expand All @@ -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"],
Expand Down
6 changes: 6 additions & 0 deletions src/locales/cy/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/locales/en/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
130 changes: 130 additions & 0 deletions src/views/drivingLicence/consent.html
Original file line number Diff line number Diff line change
@@ -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") %}

<h1 id="header" data-page="{{hmpoPageKey}}" class="govuk-heading-l">
{{ translate("pages.consent.titleDVA") }}
</h1>
<p>
{{ translate("pages.consent.checkDVA") }}
</p>
<h2 >{{ translate("drivingLicence.consentDVA") }}</h2>

{{ hmpoText(ctx, {
id: "issuerDependent",
type: "hidden",
legend: "",
default: "DVA"
}) }}

{{ hmpoCheckboxes(ctx, {
id: "consentDVACheckbox",
hint: {
classes: "govuk-label"
}
}) }}

{% endif %}

{% if (values.licenceIssuer == "DVLA") %}

<h1 id="header" data-page="{{hmpoPageKey}}" class="govuk-heading-l">
{{ translate("pages.consent.title") }}
</h1>
<p>
{{ translate("pages.consent.checkDVLA") }}
</p>
<h2 >{{ translate("drivingLicence.consentDVLA") }}</h2>

{{ 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 ()}}

<script nonce="{{ cspNonce }}">
var formSubmitted = false;

submitSpinner()

function delayDisableButton(button) {
button.className += ' button--spinner'
setTimeout(function () {
button.setAttribute('disabled', 'disabled')
}, 200);
}

function submitSpinner() {
var selects = document.getElementById('continue')

selects.addEventListener('click', function (event) {
if (!formSubmitted) {
formSubmitted = true;

delayDisableButton(event.target);
} else {
event.preventDefault()
}
})
}

window.addEventListener('load', function () {
window
.DI
.analyticsGa4
.pageViewTracker
.trackOnPageLoad({
statusCode: '200', // Access status code
englishPageTitle: '{{translate("pages.check.title")}}',
taxonomy_level1: 'web cri', // Access taxonomy level 1
taxonomy_level2: 'fraud', // Access taxonomy level 2
content_id: '001',
logged_in_status: true,
dynamic: false
});
});
</script>

{% endblock %}

{% set footerNavItems = translate("govuk.footerNavItems") %}

{% block footer %}
{{ govukFooter( footerNavItems ) }}
{% endblock %}

0 comments on commit df9de76

Please sign in to comment.