From 706e4481ff092188939bb7318954463ce8a85ecf Mon Sep 17 00:00:00 2001 From: ttingle-ch Date: Wed, 18 Dec 2024 11:51:13 +0000 Subject: [PATCH] Updated limited name registered with aml body screen to use the new njk template --- locales/cy/name-registered-with-aml.json | 1 + locales/en/name-registered-with-aml.json | 1 + .../nameRegisteredWithAmlController.ts | 20 ++++---- .../name-registered-with-aml.njk | 49 +++++++++++++++++++ .../nameRegisteredWithAmlController.test.ts | 5 +- 5 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 src/views/features/limited/name-registered-with-aml/name-registered-with-aml.njk diff --git a/locales/cy/name-registered-with-aml.json b/locales/cy/name-registered-with-aml.json index a73aab122..b5276ecb4 100644 --- a/locales/cy/name-registered-with-aml.json +++ b/locales/cy/name-registered-with-aml.json @@ -4,6 +4,7 @@ "nameRegisteredWithAmlNameOfTheBusinessOption": "Enw'r busnes", "nameRegisteredWithAmlYourNameOption": "Eich enw", "nameRegisteredWithAmlBothOption": "Y ddau", + "nameRegisteredWithAmlDifferentNameOption": "A different name Welsh", "error-nameRegisteredWithAmlSelectRadio" : "Dewiswch pa enw sydd wedi'i gofrestru gyda'ch corff goruchwylio AML" } \ No newline at end of file diff --git a/locales/en/name-registered-with-aml.json b/locales/en/name-registered-with-aml.json index ed0253305..5aefd2c24 100644 --- a/locales/en/name-registered-with-aml.json +++ b/locales/en/name-registered-with-aml.json @@ -4,6 +4,7 @@ "nameRegisteredWithAmlNameOfTheBusinessOption": "Name of the business", "nameRegisteredWithAmlYourNameOption": "Your name", "nameRegisteredWithAmlBothOption": "Both", + "nameRegisteredWithAmlDifferentNameOption": "A different name", "error-nameRegisteredWithAmlSelectRadio" : "Select which name is registered with your AML supervisory body" } \ No newline at end of file diff --git a/src/controllers/features/limited/nameRegisteredWithAmlController.ts b/src/controllers/features/limited/nameRegisteredWithAmlController.ts index 84ad904b6..69393b2ad 100644 --- a/src/controllers/features/limited/nameRegisteredWithAmlController.ts +++ b/src/controllers/features/limited/nameRegisteredWithAmlController.ts @@ -23,10 +23,11 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { // get data from mongo and save to session const acspData = await getAcspRegistration(session, session.getExtraData(SUBMISSION_ID)!, res.locals.applicationId); saveDataInSession(req, USER_DATA, acspData); - res.render(config.NAME_REGISTERED_WITH_AML, { + res.render(config.LIMITED_NAME_REGISTERED_WITH_AML, { previousPage, ...getLocaleInfo(locales, lang), currentUrl, + businessName: acspData?.businessName, nameRegisteredWithAml: acspData?.howAreYouRegisteredWithAml }); } catch (err) { @@ -48,26 +49,25 @@ export const post = async (req: Request, res: Response, next: NextFunction) => { const acspData : AcspData = session?.getExtraData(USER_DATA)!; if (!errorList.isEmpty()) { const pageProperties = getPageProperties(formatValidationError(errorList.array(), lang)); - res.status(400).render(config.NAME_REGISTERED_WITH_AML, { + res.status(400).render(config.LIMITED_NAME_REGISTERED_WITH_AML, { previousPage, ...getLocaleInfo(locales, lang), currentUrl, + businessName: acspData?.businessName, ...pageProperties }); } else { if (acspData) { + // save data to mongodb acspData.howAreYouRegisteredWithAml = req.body.nameRegisteredWithAml; + const acspDataService = new AcspDataService(); + await acspDataService.saveAcspData(session, acspData); } - // save data to mongodb - const acspDataService = new AcspDataService(); - await acspDataService.saveAcspData(session, acspData); - const nextPageUrl = addLangToUrl(BASE_URL + LIMITED_WHAT_IS_THE_CORRESPONDENCE_ADDRESS, lang); - const nextPageUrlForBoth = addLangToUrl(BASE_URL + LIMITED_BUSINESS_MUSTBE_AML_REGISTERED_KICKOUT, lang); - if (selectedOption === "YOUR_NAME") { - res.redirect(nextPageUrlForBoth); // Redirect to another page when your name selected + if (selectedOption === "NAME_OF_THE_BUSINESS") { + res.redirect(addLangToUrl(BASE_URL + LIMITED_WHAT_IS_THE_CORRESPONDENCE_ADDRESS, lang)); } else { - res.redirect(nextPageUrl); // Redirect to the sector page for the other 2 options + res.redirect(addLangToUrl(BASE_URL + LIMITED_BUSINESS_MUSTBE_AML_REGISTERED_KICKOUT, lang)); } } } catch (err) { diff --git a/src/views/features/limited/name-registered-with-aml/name-registered-with-aml.njk b/src/views/features/limited/name-registered-with-aml/name-registered-with-aml.njk new file mode 100644 index 000000000..f6fa7c5c5 --- /dev/null +++ b/src/views/features/limited/name-registered-with-aml/name-registered-with-aml.njk @@ -0,0 +1,49 @@ +{% from "govuk/components/radios/macro.njk" import govukRadios %} +{% from "govuk/components/button/macro.njk" import govukButton %} + +{% extends "layouts/default.njk" %} +{% set title = i18n.nameRegisteredWithAmlTitle %} +{% block main_content %} +
+ {{ govukRadios({ + errorMessage: errors.nameRegisteredWithAml if errors, + classes: "govuk-radios", + id: "name-registered-with-aml-radios", + name: "nameRegisteredWithAml", + fieldset: { + legend: { + text: i18n.nameRegisteredWithAmlTitle, + isPageHeading: true, + classes: "govuk-fieldset__legend--l" + } + }, + hint: { + text: i18n.nameRegisteredWithAmlBody + }, + value: nameRegisteredWithAml, + items: [ + { + value: "NAME_OF_THE_BUSINESS", + text: businessName, + id:"name-of-the-business-option-id" + }, + { + value: "A_DIFFERENT_NAME", + text: i18n.nameRegisteredWithAmlDifferentNameOption, + id:"different-name-option-id" + } + ] + }) }} + {{ govukButton({ + text: i18n.SaveAndContinue, + id:"save-continue-button" + }) }} +
+ + + +{% endblock main_content %} \ No newline at end of file diff --git a/test/src/controllers/limited/nameRegisteredWithAmlController.test.ts b/test/src/controllers/limited/nameRegisteredWithAmlController.test.ts index 744050b56..4ecc564a6 100644 --- a/test/src/controllers/limited/nameRegisteredWithAmlController.test.ts +++ b/test/src/controllers/limited/nameRegisteredWithAmlController.test.ts @@ -55,10 +55,7 @@ describe("POST" + LIMITED_NAME_REGISTERED_WITH_AML, () => { }); it("should return status 302 after redirect", async () => { - const formData = { - id: "abc", - nameRegisteredWithAml: "YOUR_NAME" - }; + const formData = { nameRegisteredWithAml: "A_DIFFERENT_NAME" }; const res = await router.post(BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML).send(formData); expect(res.status).toBe(302); expect(res.header.location).toBe(BASE_URL + LIMITED_BUSINESS_MUSTBE_AML_REGISTERED_KICKOUT + "?lang=en");