Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline error #1728

Open
wants to merge 3 commits into
base: c100-value-add
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/steps/c100-rebuild/check-your-answers/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ const safteyConcenFilledSection = (userCase, contentLanguage, language) => {
export const commonSectionsForContentLoader = (contentLanguage, userCase, language) => {
return {
PostCodeAndTypeOfApplication: [
LocationDetails(contentLanguage, userCase),
LocationDetails(contentLanguage, userCase, language),
TypeOfApplication(contentLanguage, userCase, language),
],
ScreeingQuestions: [
Expand All @@ -525,7 +525,7 @@ export const commonSectionsForContentLoader = (contentLanguage, userCase, langua
export const CheckYourAnswerFlow1 = (userCase, contentLanguage, language) => {
return [
...commonSectionsForContentLoader(contentLanguage, userCase, language).PostCodeAndTypeOfApplication,
TypeOfOrder(contentLanguage, userCase),
TypeOfOrder(contentLanguage, userCase, language),
WithoutNoticeHearing(contentLanguage, userCase, language),
peopleSections(userCase, contentLanguage, language),
PastAndCurrentProceedings(contentLanguage, userCase, language),
Expand All @@ -542,7 +542,7 @@ export const CheckYourAnswerFlow2 = (userCase, contentLanguage, language) => {
MiamTitle(contentLanguage),
MiamAttendance(contentLanguage, userCase, language),
PastAndCurrentProceedings(contentLanguage, userCase, language),
TypeOfOrder(contentLanguage, userCase),
TypeOfOrder(contentLanguage, userCase, language),
WithoutNoticeHearing(contentLanguage, userCase, language),
peopleSections(userCase, contentLanguage, language),
SafetyConcerns(contentLanguage, userCase, language),
Expand All @@ -558,7 +558,7 @@ export const CheckYourAnswerFlow3 = (userCase, contentLanguage, newContents, lan
...commonSectionsForContentLoader(contentLanguage, userCase, language).MIAM_ALL,
MiamExemption(newContents, userCase, language),
WithoutNoticeHearing(contentLanguage, userCase, language),
TypeOfOrder(contentLanguage, userCase),
TypeOfOrder(contentLanguage, userCase, language),
peopleSections(userCase, contentLanguage, language),
PastAndCurrentProceedings(contentLanguage, userCase, language),
SafetyConcerns(contentLanguage, userCase, language),
Expand All @@ -573,7 +573,7 @@ export const CheckYourAnswerFlow4 = (userCase, contentLanguage, newContents, lan
...commonSectionsForContentLoader(contentLanguage, userCase, language).ScreeingQuestions,
...commonSectionsForContentLoader(contentLanguage, userCase, language).MIAM_ALL,
MiamExemption(newContents, userCase, language),
TypeOfOrder(contentLanguage, userCase),
TypeOfOrder(contentLanguage, userCase, language),
WithoutNoticeHearing(contentLanguage, userCase, language),
peopleSections(userCase, contentLanguage, language),
PastAndCurrentProceedings(contentLanguage, userCase, language),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { YesOrNo } from '../../../../app/case/definition';
import { HTML } from '../common/htmlSelectors';
import { getYesNoTranslation } from '../mainUtil';
import { getYesNoTranslation, translation } from '../mainUtil';

const htmlValParser = (selection, subText, keys) => {
selection = selection || '';
subText = subText || '';
const htmlValParser = (selection, subText, keys, language, istrue) => {
selection = selection || HTML.ERROR_MESSAGE_SPAN + translation('completeSectionError', language) + HTML.SPAN_CLOSE;
if (!subText) {
subText = istrue ? HTML.ERROR_MESSAGE_SPAN + translation('completeSectionError', language) + HTML.SPAN_CLOSE : '';
}
const addDetails = subText
? HTML.ROW_START_NO_BORDER +
HTML.DESCRIPTION_TERM_ELEMENT +
Expand Down Expand Up @@ -57,8 +59,15 @@ const getValueUrlByKey = (key: string, userCase: any, language: any, Urls: any,
url = Urls['C100_INTERNATIONAL_ELEMENTS_REQUEST'];
break;
}
const istrue = caseDataYesNo === YesOrNo.YES;
return {
valueHtml: htmlValParser(getYesNoTranslation(language, caseDataYesNo, 'ydyntTranslation'), caseDataDetail, keys),
valueHtml: htmlValParser(
getYesNoTranslation(language, caseDataYesNo, 'ydyntTranslation'),
caseDataDetail,
keys,
language,
istrue
),
changeUrl: url,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('courtOrderHelper test case', () => {
});

test('courtTypeOfOrderHelper functionality testing', () => {
const data = courtTypeOfOrderHelper(userCase, keys, userKey);
const data = courtTypeOfOrderHelper(userCase, keys, userKey, 'en');
expect(data).toBe(
'<ul class="govuk-list govuk-list--bullet"><li>test data</li><li>test data</li><li>test data</li></ul>'
);
Expand All @@ -48,7 +48,7 @@ describe('courtOrderHelper test case', () => {
});

test('courtTypeOfOrder functionality testing', () => {
const data = courtTypeOfOrder(userCase, keys, userKey);
const data = courtTypeOfOrder(userCase, keys, userKey, 'en');
expect(data).toBe(
'<ul class="govuk-list govuk-list--bullet"><li>test data</li><li>test data</li><li>test data</li></ul>'
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { HTML } from '../common/htmlSelectors';
import { translation } from '../mainUtil';

export const courtOrderSubFieldParser = (userCase, keys, userKey, originalListItem) => {
if (userCase.hasOwnProperty(userKey)) {
Expand Down Expand Up @@ -34,7 +35,7 @@ export const courtOrderParentAndChildFieldParser = (userCase, keys, sessionKey)
}
};

export const courtTypeOfOrder = (userCase, keys, sessionKey) => {
export const courtTypeOfOrder = (userCase, keys, sessionKey, language) => {
if (userCase.hasOwnProperty(sessionKey)) {
const mappedVals = userCase[sessionKey]
.filter(val => val !== '')
Expand All @@ -51,11 +52,13 @@ export const courtTypeOfOrder = (userCase, keys, sessionKey) => {
}
});
return (HTML.UNORDER_LIST + mappedVals + HTML.UNORDER_LIST_END).split(',').join('');
} else {
return HTML.ERROR_MESSAGE_SPAN + translation('completeSectionError', language) + HTML.SPAN_CLOSE;
}
};

export const courtTypeOfOrderHelper = (userCase, keys, sessionKey) => {
return courtTypeOfOrder(userCase, keys, sessionKey);
export const courtTypeOfOrderHelper = (userCase, keys, sessionKey, language) => {
return courtTypeOfOrder(userCase, keys, sessionKey, language);
};

export const CourtOrderParserHelper = (userCase, keys, sessionKey) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { YesOrNo } from '../../../../../main/app/case/definition';
import { CaseWithId } from '../../../../app/case/case';
import { HTML } from '../common/htmlSelectors';
import { getYesNoTranslation } from '../mainUtil';
import { getYesNoTranslation, populateError } from '../mainUtil';

export const hearingDetailsHelper = (userCase, keys, sessionKey, language) => {
if (userCase.hasOwnProperty(sessionKey)) {
Expand Down Expand Up @@ -85,7 +85,11 @@ export const hearingDetailsHelper = (userCase, keys, sessionKey, language) => {
export const hearingDetailsQualifyForFirstHearingHelper = (userCase, keys, sessionKey, language) => {
if (userCase.hasOwnProperty(sessionKey)) {
let html = generateStartBorderHtml(userCase, 'hu_urgentHearingReasons');
html += getYesNoTranslation(language, userCase['hu_urgentHearingReasons'], 'oesTranslation');
html += populateError(
userCase['hu_urgentHearingReasons'],
getYesNoTranslation(language, userCase['hu_urgentHearingReasons'], 'oesTranslation'),
language
);
if (userCase.hasOwnProperty('hu_urgentHearingReasons') && userCase['hu_urgentHearingReasons'] === 'Yes') {
html += HTML.DESCRIPTION_TERM_DETAIL_END;
html += HTML.ROW_END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '../../../../steps/urls';
import { HTML } from '../common/htmlSelectors';
import { ANYTYPE } from '../common/index';
import { getYesNoTranslation } from '../mainUtil';
import { getYesNoTranslation, populateError } from '../mainUtil';

class MiamHelperDataParser<T> {
[x: string]: T;
Expand Down Expand Up @@ -59,7 +59,11 @@ const generateDomesticAbuseAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START +
HTML.DESCRIPTION_TERM_DETAIL +
getYesNoTranslation(language, userCase.miam_canProvideDomesticAbuseEvidence, 'gallafTranslation') +
populateError(
userCase.miam_canProvideDomesticAbuseEvidence,
getYesNoTranslation(language, userCase.miam_canProvideDomesticAbuseEvidence, 'gallafTranslation'),
language
) +
HTML.DESCRIPTION_TERM_DETAIL_END +
HTML.ROW_END +
HTML.ROW_START +
Expand All @@ -74,10 +78,16 @@ const generateDomesticAbuseAdditionalFields = (
(userCase.miam_canProvideDomesticAbuseEvidence === YesOrNo.YES
? HTML.UNORDER_LIST +
userCase.miam_domesticAbuseEvidenceDocs?.map(doc => {
return HTML.LIST_ITEM + doc.document_filename + HTML.LIST_ITEM_END;
return (
HTML.LIST_ITEM + populateError(doc.document_filename, doc.document_filename, language) + HTML.LIST_ITEM_END
);
}) +
HTML.UNORDER_LIST_END
: userCase.miam_detailsOfDomesticAbuseEvidence)
: populateError(
userCase.miam_detailsOfDomesticAbuseEvidence,
userCase.miam_detailsOfDomesticAbuseEvidence,
language
))
);
};

Expand All @@ -97,8 +107,12 @@ const generateNCDRAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START +
HTML.DESCRIPTION_TERM_DETAIL +
getYesNoTranslation(language, userCase.miam_haveDocSignedByMediatorForPrevAttendance, 'oesTranslation') +
HTML.DESCRIPTION_TERM_DETAIL_END;
populateError(
userCase.miam_haveDocSignedByMediatorForPrevAttendance,
getYesNoTranslation(language, userCase.miam_haveDocSignedByMediatorForPrevAttendance, 'oesTranslation') +
HTML.DESCRIPTION_TERM_DETAIL_END,
language
);
}

if (userCase.miam_haveDocSignedByMediatorForPrevAttendance === YesOrNo.NO) {
Expand All @@ -111,8 +125,11 @@ const generateNCDRAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START_NO_BORDER +
HTML.DESCRIPTION_TERM_DETAIL +
userCase.miam_detailsOfEvidence +
HTML.DESCRIPTION_TERM_DETAIL_END;
populateError(
userCase.miam_detailsOfEvidence,
userCase.miam_detailsOfEvidence + HTML.DESCRIPTION_TERM_DETAIL_END,
language
);
}

if (
Expand All @@ -128,17 +145,22 @@ const generateNCDRAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START_NO_BORDER +
HTML.DESCRIPTION_TERM_DETAIL +
userCase.miam_previousAttendanceEvidenceDoc?.document_filename +
HTML.DESCRIPTION_TERM_DETAIL_END +
HTML.ROW_END;
populateError(
userCase.miam_previousAttendanceEvidenceDoc?.document_filename,
userCase.miam_previousAttendanceEvidenceDoc?.document_filename +
HTML.DESCRIPTION_TERM_DETAIL_END +
HTML.ROW_END,
language
);
}

return additionalFields;
};

const generateOtherExemptionAdditionalFields = (
userCase: Partial<CaseWithId>,
keys: Record<string, string>
keys: Record<string, string>,
language: string
): string => {
let additionalFields = '';
if (userCase.miam_notAttendingReasons === Miam_notAttendingReasons.canNotAccessMediator) {
Expand All @@ -163,9 +185,11 @@ const generateOtherExemptionAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START_NO_BORDER +
HTML.DESCRIPTION_TERM_DETAIL +
userCase.miam_noAppointmentAvailableDetails +
HTML.DESCRIPTION_TERM_ELEMENT_END +
HTML.ROW_END;
populateError(
userCase.miam_noAppointmentAvailableDetails,
userCase.miam_noAppointmentAvailableDetails + HTML.DESCRIPTION_TERM_ELEMENT_END + HTML.ROW_END,
language
);
}

if (userCase.miam_noMediatorReasons === Miam_noMediatorReasons.disability) {
Expand All @@ -178,9 +202,11 @@ const generateOtherExemptionAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START_NO_BORDER +
HTML.DESCRIPTION_TERM_DETAIL +
userCase.miam_unableToAttainDueToDisablityDetails +
HTML.DESCRIPTION_TERM_ELEMENT_END +
HTML.ROW_END;
populateError(
userCase.miam_unableToAttainDueToDisablityDetails,
userCase.miam_unableToAttainDueToDisablityDetails + HTML.DESCRIPTION_TERM_ELEMENT_END + HTML.ROW_END,
language
);
}

if (userCase.miam_noMediatorReasons === Miam_noMediatorReasons.noMediatorIn15mile) {
Expand All @@ -193,9 +219,11 @@ const generateOtherExemptionAdditionalFields = (
HTML.ROW_END +
HTML.ROW_START +
HTML.DESCRIPTION_TERM_DETAIL +
userCase.miam_noMediatorIn15mileDetails +
HTML.DESCRIPTION_TERM_ELEMENT_END +
HTML.ROW_END;
populateError(
userCase.miam_noMediatorIn15mileDetails,
userCase.miam_noMediatorIn15mileDetails + HTML.DESCRIPTION_TERM_ELEMENT_END + HTML.ROW_END,
language
);
}
}

Expand Down Expand Up @@ -239,7 +267,7 @@ export const miamParentAndChildFieldParser = (
sessionKey === 'miam_notAttendingReasons' &&
userCase.miam_notAttendingReasons !== Miam_notAttendingReasons.none
) {
additionalFields = generateOtherExemptionAdditionalFields(userCase, keys).split(',').join('');
additionalFields = generateOtherExemptionAdditionalFields(userCase, keys, language).split(',').join('');
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
/* eslint-disable prettier/prettier */
import _ from 'lodash';
import { HTML } from '../common/htmlSelectors';
import { getYesNoTranslation, isBorderPresent } from '../mainUtil';
import { getYesNoTranslation, isBorderPresent, populateError, translation } from '../mainUtil';

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
export const applicantAddressParser = (sessionApplicantData, keys,language) => {
let html = HTML.DESCRIPTION_LIST+HTML.ROW_START+HTML.DESCRIPTION_TERM_DETAIL;
if(!_.isEmpty(sessionApplicantData['applicantAddress1']) &&
!_.isEmpty(sessionApplicantData['applicantAddressTown']) &&
!_.isEmpty(sessionApplicantData['applicantAddressCounty']) &&
!_.isEmpty(sessionApplicantData['applicantAddressPostcode'])
){
html+= sessionApplicantData.hasOwnProperty('applicantAddress1') && sessionApplicantData['applicantAddress1'] !== '' ? sessionApplicantData['applicantAddress1'] + HTML.BREAK : '';
html+= sessionApplicantData.hasOwnProperty('applicantAddress2') && sessionApplicantData['applicantAddress2'] !== '' ? sessionApplicantData['applicantAddress2'] + HTML.BREAK : '';
html+= sessionApplicantData.hasOwnProperty('applicantAddressTown') && sessionApplicantData['applicantAddressTown'] !== '' ? sessionApplicantData['applicantAddressTown'] + HTML.BREAK: '';
html+= sessionApplicantData.hasOwnProperty('applicantAddressCounty') && sessionApplicantData['applicantAddressCounty'] !== '' ? sessionApplicantData['applicantAddressCounty'] + HTML.BREAK + HTML.BREAK : '';
html+= sessionApplicantData.hasOwnProperty('applicantAddressPostcode') && sessionApplicantData['applicantAddressPostcode'] !== '' ? sessionApplicantData['applicantAddressPostcode'] : '';
html+=HTML.DESCRIPTION_TERM_DETAIL_END+ HTML.ROW_END;
if(sessionApplicantData.hasOwnProperty('applicantAddressHistory')){
}else {
html+= HTML.ERROR_MESSAGE_SPAN + translation('completeSectionError', language) + HTML.SPAN_CLOSE

html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_ELEMENT + keys['haveLivedMore'] +HTML.DESCRIPTION_TERM_ELEMENT_END+ HTML.ROW_END;
html +=isBorderPresent(sessionApplicantData['applicantAddressHistory'],'Yes');
html += HTML.DESCRIPTION_TERM_DETAIL +getYesNoTranslation(language,sessionApplicantData?.['applicantAddressHistory'],'doTranslation')+HTML.DESCRIPTION_TERM_DETAIL_END+ HTML.ROW_END;
html += HTML.DESCRIPTION_TERM_DETAIL +populateError(sessionApplicantData?.['applicantAddressHistory'],getYesNoTranslation(language,sessionApplicantData?.['applicantAddressHistory'],'doTranslation')+HTML.DESCRIPTION_TERM_DETAIL_END+ HTML.ROW_END,language);
if(sessionApplicantData['applicantAddressHistory'] === 'Yes'){
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_ELEMENT + keys['previousAddress'] +HTML.DESCRIPTION_TERM_ELEMENT_END+ HTML.ROW_END;
sessionApplicantData.hasOwnProperty('applicantProvideDetailsOfPreviousAddresses')&& (html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +sessionApplicantData?.['applicantProvideDetailsOfPreviousAddresses'] +HTML.DESCRIPTION_TERM_DETAIL_END+ HTML.ROW_END);
populateError(sessionApplicantData?.['applicantProvideDetailsOfPreviousAddresses'] , HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +sessionApplicantData?.['applicantProvideDetailsOfPreviousAddresses'],language+HTML.DESCRIPTION_TERM_DETAIL_END+ HTML.ROW_END);
}

}
Expand Down Expand Up @@ -51,38 +59,38 @@ export const applicantAddressParserForRespondents = (sessionApplicantData, keys,
return html;
};
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
export const applicantContactDetailsParser = (sessionApplicantData, keys): string => {
export const applicantContactDetailsParser = (sessionApplicantData, keys,language): string => {
let html = HTML.DESCRIPTION_LIST as string;
if(sessionApplicantData['canProvideEmail'] === 'Yes'){
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_ELEMENT + keys['canProvideEmailLabel'] + HTML.DESCRIPTION_TERM_ELEMENT_END+HTML.ROW_END;
html += HTML.ROW_START+HTML.DESCRIPTION_TERM_DETAIL +sessionApplicantData['emailAddress']+ HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
html += HTML.ROW_START+HTML.DESCRIPTION_TERM_DETAIL +populateError(sessionApplicantData['emailAddress'],sessionApplicantData['emailAddress'],language) + HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
}
if(sessionApplicantData['canProvideEmail'] === 'No'){
html += HTML.ROW_START+HTML.DESCRIPTION_TERM_ELEMENT + keys['canNotProvideEmailLabel'] + HTML.DESCRIPTION_TERM_ELEMENT_END+HTML.ROW_END;
}

if(sessionApplicantData['canProvideTelephoneNumber'] === 'Yes'){
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_ELEMENT +keys['canProvideTelephoneNumberLabel'] + HTML.DESCRIPTION_TERM_ELEMENT_END+HTML.ROW_END;
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +sessionApplicantData['telephoneNumber'] +HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +populateError(sessionApplicantData['telephoneNumber'],sessionApplicantData['telephoneNumber'],language) +HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
}
if(sessionApplicantData['canProvideTelephoneNumber'] === 'No'){
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_ELEMENT + keys['canNotProvideTelephoneNumberLabel'] + HTML.DESCRIPTION_TERM_ELEMENT_END+HTML.ROW_END;
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +sessionApplicantData['canNotProvideTelephoneNumberReason']+HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
html += HTML.ROW_START_NO_BORDER+HTML.DESCRIPTION_TERM_DETAIL +populateError(sessionApplicantData['canNotProvideTelephoneNumberReason'],sessionApplicantData['canNotProvideTelephoneNumberReason'],language)+HTML.DESCRIPTION_TERM_DETAIL_END+HTML.ROW_END;
//canNotProvideMobileNumberReason
}
return html;
};



export const applicantCourtCanLeaveVoiceMail = (sessionApplicantData, keys) => {
export const applicantCourtCanLeaveVoiceMail = (sessionApplicantData, keys,language) => {
let html = '' as string;
if(sessionApplicantData['canLeaveVoiceMail'] === 'Yes'){
html += keys['voiceMailYesLabel'];
}
if(sessionApplicantData['canLeaveVoiceMail'] === 'No'){
}else if(sessionApplicantData['canLeaveVoiceMail'] === 'No'){
html += keys['voiceMailNoLabel'];
}
}else
html+=HTML.ERROR_MESSAGE_SPAN + translation('completeSectionError', language) + HTML.SPAN_CLOSE
return html;
};

Expand Down
Loading