diff --git a/src/controllers/features/sole-trader/whereDoYouLiveController.ts b/src/controllers/features/sole-trader/whereDoYouLiveController.ts index b94a4086b..0094213cc 100644 --- a/src/controllers/features/sole-trader/whereDoYouLiveController.ts +++ b/src/controllers/features/sole-trader/whereDoYouLiveController.ts @@ -26,7 +26,7 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { const acspData = await getAcspRegistration(session, session.getExtraData(SUBMISSION_ID)!, res.locals.applicationId); saveDataInSession(req, USER_DATA, acspData); - const { payload, countryInput } = new WhereDoYouLivBodyService().getCountryPayload(acspData); + const payload = new WhereDoYouLivBodyService().getCountryPayload(acspData); res.render(config.SOLE_TRADER_WHERE_DO_YOU_LIVE, { ...getLocaleInfo(locales, lang), previousPage, @@ -34,7 +34,6 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { countryList: countryList, firstName: acspData?.applicantDetails?.firstName, lastName: acspData?.applicantDetails?.lastName, - countryInput, payload }); } catch (err) { diff --git a/src/controllers/features/update-acsp/whereDoYouLiveController.ts b/src/controllers/features/update-acsp/whereDoYouLiveController.ts index ca2af68da..f9acdfa41 100644 --- a/src/controllers/features/update-acsp/whereDoYouLiveController.ts +++ b/src/controllers/features/update-acsp/whereDoYouLiveController.ts @@ -21,7 +21,7 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { // This ensures functionality until the page is ready, at which point we can handle null separately. const acspData: AcspData = session.getExtraData(USER_DATA) ? session.getExtraData(USER_DATA)! : {}; - const { payload, countryInput } = new WhereDoYouLivBodyService().getCountryPayload(acspData); + const payload = new WhereDoYouLivBodyService().getCountryPayload(acspData); const reqType = REQ_TYPE_UPDATE_ACSP; res.render(config.SOLE_TRADER_WHERE_DO_YOU_LIVE, { ...getLocaleInfo(locales, lang), @@ -30,7 +30,6 @@ export const get = async (req: Request, res: Response, next: NextFunction) => { countryList: countryList, firstName: acspData?.applicantDetails?.firstName, lastName: acspData?.applicantDetails?.lastName, - countryInput, payload, reqType }); diff --git a/src/services/where-do-you-live/whereDoYouLive.ts b/src/services/where-do-you-live/whereDoYouLive.ts index 42aea18c9..751937723 100644 --- a/src/services/where-do-you-live/whereDoYouLive.ts +++ b/src/services/where-do-you-live/whereDoYouLive.ts @@ -1,25 +1,26 @@ import { AcspData } from "@companieshouse/api-sdk-node/dist/services/acsp"; export class WhereDoYouLivBodyService { - public getCountryPayload (ascpData: AcspData): { payload: any, countryInput?: string } { + public getCountryPayload (ascpData: AcspData) { let payload = {}; - let countryInput: string | undefined; - switch (ascpData.applicantDetails?.countryOfResidence) { + if (!ascpData.applicantDetails?.countryOfResidence) { + return payload; + } + + switch (ascpData.applicantDetails.countryOfResidence) { case "England": case "Scotland": case "Wales": case "Northern Ireland": - payload = { whereDoYouLiveRadio: ascpData?.applicantDetails?.countryOfResidence }; + payload = { whereDoYouLiveRadio: ascpData.applicantDetails?.countryOfResidence }; break; default: - if (ascpData.applicantDetails?.countryOfResidence) { - payload = { whereDoYouLiveRadio: "countryOutsideUK" }; - countryInput = ascpData.applicantDetails?.countryOfResidence; - } - break; - + payload = { + whereDoYouLiveRadio: "countryOutsideUK", + countryInput: ascpData.applicantDetails.countryOfResidence + }; } - return { payload, countryInput }; + return payload; } } diff --git a/src/views/common/correspondence-address-manual/capture-correspondence-address-manual.njk b/src/views/common/correspondence-address-manual/capture-correspondence-address-manual.njk index c419cf721..332722e98 100644 --- a/src/views/common/correspondence-address-manual/capture-correspondence-address-manual.njk +++ b/src/views/common/correspondence-address-manual/capture-correspondence-address-manual.njk @@ -88,7 +88,6 @@ {% set dropdownDefaultText = i18n.whereDoYouLiveDefaultDropdownText %} {% if payload.countryInput | length %} {% set dropdownValue = payload.countryInput %} - {% set countryInput = payload.countryInput %} {% endif %}

{{ i18n.whereDoYouLiveHint }}

diff --git a/src/views/partials/country-typeahead-input.njk b/src/views/partials/country-typeahead-input.njk index 69a98edc2..1a77853ff 100644 --- a/src/views/partials/country-typeahead-input.njk +++ b/src/views/partials/country-typeahead-input.njk @@ -2,7 +2,7 @@