Skip to content

Commit

Permalink
Updated limited name registered with aml body screen to use the new n…
Browse files Browse the repository at this point in the history
…jk template
  • Loading branch information
ttingle-ch committed Dec 18, 2024
1 parent 6e362f2 commit 706e448
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
1 change: 1 addition & 0 deletions locales/cy/name-registered-with-aml.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions locales/en/name-registered-with-aml.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
20 changes: 10 additions & 10 deletions src/controllers/features/limited/nameRegisteredWithAmlController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %}
<form action="" method="POST">
{{ 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"
}) }}
</form>

<script>
trackEventBasedOnPageTitle("name-of-the-business-option-id", "{{title}}", "select-option", "name-of-the-business");
trackEventBasedOnPageTitle("different-name-option-id", "{{title}}", "select-option", "different-name");
trackEventBasedOnPageTitle("save-continue-button", "{{title}}", "click-button", "SAVE AND CONTINUE - Name registered with AML");
</script>

{% endblock main_content %}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 706e448

Please sign in to comment.