diff --git a/components/admin/tabs/appeals.js b/components/admin/tabs/appeals.js index d7fd0c3b..7f6a35f1 100644 --- a/components/admin/tabs/appeals.js +++ b/components/admin/tabs/appeals.js @@ -6,6 +6,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import PaginationControl from "../../../components/search/pagination"; import { connect } from "react-redux"; +import transLookup from "../../../data/lookuptranslations.json"; import { setSearchResults, @@ -15,6 +16,7 @@ import { import { getDetailsProxy, getSearchDetailsPaged, hasOwn } from "../../utils"; import { getAdvancedSearchPaged } from "../../../actions/services/searchService"; import { getNewAppealsPage } from "../../../actions/services/adminService"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import { setCurrentPage, setCurrentReference @@ -416,20 +418,14 @@ function AppealsTab(props) { {hasOwn(item, [ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ]) - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ + ? resolveCrmDisplayValue({ + value: item[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""}
@@ -439,20 +435,14 @@ function AppealsTab(props) { )} : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
@@ -462,20 +452,14 @@ function AppealsTab(props) { : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
{item[ diff --git a/components/admin/tabs/documents.js b/components/admin/tabs/documents.js index 122b194f..b9bc8709 100644 --- a/components/admin/tabs/documents.js +++ b/components/admin/tabs/documents.js @@ -21,6 +21,8 @@ import { getNewDocumentsPaged } from "../../../actions/services/adminService"; import { setCurrentPage } from "../../../store/currentView/action"; import { setDocumentDetails } from "../../../store/searchOutput/action"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; + const getDocumentTypes = [ { "Value": 846040009, @@ -397,19 +399,11 @@ const DocumentsTab = (props) => { className="govuk-label-s govuk-checkboxes__label" htmlFor={item.Value} > - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item.Label + - '")].value_cy', - json: transLookup, - eval: true - }) - : item.Label || - t( - "case:summary-no-date-entered-label" - )}{" "} + {resolveCrmDisplayValue({ + value: item.Label, + locale, + translations: transLookup + })} ); @@ -470,19 +464,11 @@ const DocumentsTab = (props) => { className="govuk-label-s govuk-checkboxes__label" htmlFor={"origin_" + item.Value} > - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item.Label + - '")].value_cy', - json: transLookup, - eval: true - }) - : item.Label || - t( - "case:summary-no-date-entered-label" - )}{" "} + {resolveCrmDisplayValue({ + value: item.Label, + locale, + translations: transLookup + })} ); @@ -822,23 +808,16 @@ const DocumentsTab = (props) => { : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue( + { + value: detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: + transLookup + } + )}
diff --git a/components/admin/utils/serverside.js b/components/admin/utils/serverside.js index 20870e7f..d7a66b64 100644 --- a/components/admin/utils/serverside.js +++ b/components/admin/utils/serverside.js @@ -37,7 +37,7 @@ export async function fetchAdminStorageData() { const limit = pLimit(5); let data = await Promise.all( users.map(async (user) => { - limit(async () => { + return limit(async () => { const containers = await listContainersForUser( blobServiceClient, `${user.id}`, diff --git a/components/case.js b/components/case.js index 04eff767..5a4f5605 100644 --- a/components/case.js +++ b/components/case.js @@ -46,14 +46,6 @@ const Case = (props) => { mediaObj={props.mediaObj} mapTarget={props.mapTarget} /> - {showRepresentations == true && ( - - )} diff --git a/components/case/documents.js b/components/case/documents.js index d52d2036..31ef69aa 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -19,6 +19,7 @@ import { setCurrentPage } from "../../store/currentView/action"; import { setDocumentDetails } from "../../store/searchOutput/action"; import DocumentLink from "../utils/downloads"; import { useDownloadQueue } from "../utils/downloadmanager"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const DocumentDetails = (props) => { let { t, lang } = useTranslation(); @@ -92,352 +93,6 @@ const DocumentDetails = (props) => { }; let ShowDocLinks = getDocLink(docsOffline); - const DocumentView = (documentDetailsArr) => { - documentDetailsArr = documentDetailsArr.value; - - return ( - <> -

- {documentDetailsObj["@odata.count"] > 1 - ? t("case:documents-count-label-1") - : t("case:documents-count-label-1a")}{" "} - {documentDetailsObj["@odata.count"]}{" "} - {documentDetailsObj["@odata.count"] > 1 - ? t("case:documents-count-label-2") - : t("case:documents-count-label-2a")} -

-
-
-
- -
-
- {documentDetailsObj["@odata.count"] > 5 && ( -
-
- -
-
- )} -
- {ShowDocLinks && ( -
- - - - Notice - - - {t("case:documents-not-available-label")} - -
- )} -
-
-
- -
-
- {/* {t("case:documents-doc-type-label")} */} - -
-
- {/* {t("case:documents-date-published-label")} */} - -
- {/*
- {t("case:documents-size-label")} -
*/} -
- {showSpinnerState == true ? ( -
-
- {t("common:spinner-fetching-data")} - { -
-
- ) : ( - documentDetailsArr.map((item, key) => { - let detailsObj = jsonpath({ - path: - "$..[?(@ && @._pinswg_documentids_value=='" + - incidentid + - "')]", - json: item, - sanbox: {} - }); - detailsObj = item; - return ( -
-
- {showDownloadingState === key && ( -
- {/* { */} -
- )} - - {!ShowDocLinks ? ( - { - (toggleDownLoadLink(key), - sendGAEvent( - "event", - "DownloadedFile", - { - caseReference: - props.caseReference, - filename: - detailsObj.pinswg_name - } - )); - }} - > - - {t( - "case:documents-name-label" - )} - : - - {hasOwn( - detailsObj, - "pinswg_name" - ) - ? detailsObj.pinswg_name - : ""} - - ) : ( - <> - - {t( - "case:documents-name-label" - )} - : - - {hasOwn( - detailsObj, - "pinswg_name" - ) - ? detailsObj.pinswg_name - : ""} - - )} -
-
- - {t("case:documents-doc-type-label")} - : - - - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
- - {t( - "case:documents-date-published-label" - )} - : - - - {hasOwn( - detailsObj, - "pinswg_latestpublisheddate" - ) - ? formatDates( - detailsObj.pinswg_latestpublisheddate - ) - : ""} -
- {/*
- - {t("case:documents-size-label")}: - - 92 -
*/} -
- ); - }) - )} -
- - - ); - }; - const FilteredDocumentView = (documentDetailsArr) => { documentDetailsArr = documentDetailsArr.value; @@ -547,19 +202,11 @@ const DocumentDetails = (props) => { item.pinswg_isharedocumentlocations } > - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item.pinswg_isharedocumentlocationsLabel + - '")].value_cy', - json: transLookup, - eval: true - }) - : item.pinswg_isharedocumentlocationsLabel || - t( - "case:summary-no-date-entered-label" - )}{" "} + {resolveCrmDisplayValue({ + value: item.pinswg_isharedocumentlocationsLabel, + locale, + translations: transLookup + })}{" "} - ({item.count}) @@ -817,24 +464,13 @@ const DocumentDetails = (props) => { )} :
- - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}
@@ -1047,10 +683,8 @@ const DocumentDetails = (props) => { - ) : showFilteredDocs == "true" ? ( - FilteredDocumentView(documentDetailsArr) ) : ( - DocumentView(documentDetailsArr) + FilteredDocumentView(documentDetailsArr) )} diff --git a/components/case/representationList.js b/components/case/representationList.js index 14518414..50c212fd 100644 --- a/components/case/representationList.js +++ b/components/case/representationList.js @@ -88,23 +88,13 @@ const RepresentationList = (props) => { {t("case:documents-doc-type-label")}: - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - sanbox: {} - }) - : detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}
diff --git a/components/case/summaryTypes/pinswg_advertsid.js b/components/case/summaryTypes/pinswg_advertsid.js index 5b738251..b8c38cab 100644 --- a/components/case/summaryTypes/pinswg_advertsid.js +++ b/components/case/summaryTypes/pinswg_advertsid.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -24,43 +24,30 @@ const Pinswg_advertsid = (props) => {
{ />
@@ -160,23 +119,16 @@ const Pinswg_advertsid = (props) => { {t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{/* @@ -193,7 +145,9 @@ const Pinswg_advertsid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -257,7 +211,10 @@ const Pinswg_advertsid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) diff --git a/components/case/summaryTypes/pinswg_callinss77id.js b/components/case/summaryTypes/pinswg_callinss77id.js index 7e1cf8f3..7dccf347 100644 --- a/components/case/summaryTypes/pinswg_callinss77id.js +++ b/components/case/summaryTypes/pinswg_callinss77id.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -24,23 +24,16 @@ const Pinswg_callinss77id = (props) => {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_callinss77id = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -234,7 +188,10 @@ const Pinswg_callinss77id = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -247,31 +204,6 @@ const Pinswg_callinss77id = (props) => { : t("case:summary-no-date-entered-label") } /> - {/*
-
- {t( - "case:summary-date-exported-to-iss-label" - )} -
-
- {hasOwn( - detailsObj, - "pinswg_dateexportedtoiss" - ) - ? !_.isEmpty( - detailsObj.pinswg_dateexportedtoiss - ) - ? formatDates( - detailsObj.pinswg_dateexportedtoiss - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
*/} { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -341,31 +276,7 @@ const Pinswg_callinss77id = (props) => { : t("case:summary-no-date-entered-label") } /> - {/*
-
- {t( - "case:summary-inquiry-evidence-date-label" - )} -
-
- {hasOwn( - detailsObj, - "pinswg_proofsofevidencewrittenstatementsofeviden" - ) - ? !_.isEmpty( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - ? formatDates( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
*/} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_commonlandid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -203,26 +157,14 @@ const Pinswg_commonlandid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_relevantauthorityname" + ], + locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -260,7 +202,10 @@ const Pinswg_commonlandid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -331,7 +276,10 @@ const Pinswg_commonlandid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -344,31 +292,7 @@ const Pinswg_commonlandid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/*
-
- {t( - "case:summary-inquiry-evidence-date-label" - )} -
-
- {hasOwn( - detailsObj, - "pinswg_proofsofevidencewrittenstatementsofeviden" - ) - ? !_.isEmpty( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - ? formatDates( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
*/} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_communityinfrastructurelevyid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -269,7 +223,10 @@ const Pinswg_communityinfrastructurelevyid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) diff --git a/components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js b/components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js index a78e3908..a672a11f 100644 --- a/components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js +++ b/components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; @@ -23,131 +22,81 @@ const Pinswg_compulsorypurchaseordersid = (props) => {
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{casesObj.numberofchildincidents > 0 && ( @@ -190,26 +139,12 @@ const Pinswg_compulsorypurchaseordersid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
diff --git a/components/case/summaryTypes/pinswg_dnsid.js b/components/case/summaryTypes/pinswg_dnsid.js index 6a8b75c8..b30997ae 100644 --- a/components/case/summaryTypes/pinswg_dnsid.js +++ b/components/case/summaryTypes/pinswg_dnsid.js @@ -3,6 +3,7 @@ import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -96,25 +97,16 @@ const Pinswg_dnsid = (props) => { label={t( "case:summary-case-type-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> {detailsObj.pinswg_webaddress != null && ( @@ -175,23 +167,16 @@ const Pinswg_dnsid = (props) => { label={t( "case:summary-eia-required-label" )} - value={ - router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-to-be-confirmed-label" - ) - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + })} /> { value={ detailsObj.pinswg_choiceofprocedure !== null - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue" - ] + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + }) : t( "case:summary-to-be-confirmed-label" ) } /> - {/* */} - {/* */} + {
{detailsObj.pinswg_decision !== null - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + }) : t( "case:summary-no-information-to-date-label" )}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{ ) : ( "" )} - {/* */}
@@ -443,29 +359,6 @@ const Pinswg_dnsid = (props) => { {t("case:summary-dates-label")}
- {/* */} { ) } /> - {/* */} + { label={t( "case:summary-case-type-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> { label={t( "case:summary-eia-required-label" )} - value={ - router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-to-be-confirmed-label" - ) - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + })} />
@@ -131,9 +116,6 @@ const Pinswg_electricityactid = (props) => { )}
- {" "} - {/* {casesObj.caseDetails.caseOfficer || - ""} */} {hasOwn(casesObj, "_ownerid_value") ? casesObj[ "_ownerid_value@OData.Community.Display.V1.FormattedValue" @@ -145,96 +127,56 @@ const Pinswg_electricityactid = (props) => { label={t( "case:summary-procedure-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] || "" - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: "" + })} />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })}
{casesObj.numberofchildincidents > 0 && ( @@ -283,21 +225,16 @@ const Pinswg_electricityactid = (props) => { label={t( "case:summary-case-recommendation-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj.pinswg_recommendation + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj.pinswg_recommendation || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_recommendation" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> {detailsObj.pinswg_webaddress != null && ( {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_enforcementlistedbuildingconseid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_enforcementlistedbuildingconseid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_enforcementlistedbuildingconseid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -319,31 +279,7 @@ const Pinswg_enforcementlistedbuildingconseid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/*
-
- {t( - "case:summary-inquiry-evidence-date-label" - )} -
-
- {hasOwn( - detailsObj, - "pinswg_proofsofevidencewrittenstatementsofeviden" - ) - ? !_.isEmpty( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - ? formatDates( - detailsObj.pinswg_proofsofevidencewrittenstatementsofeviden - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
- */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_enforcementnoticeappeals174id = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_enforcementnoticeappeals174id = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_enforcementnoticeappeals174id = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -319,27 +279,7 @@ const Pinswg_enforcementnoticeappeals174id = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_environmentalpermittingid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -203,26 +157,12 @@ const Pinswg_environmentalpermittingid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -260,7 +200,10 @@ const Pinswg_environmentalpermittingid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -331,7 +274,10 @@ const Pinswg_environmentalpermittingid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) diff --git a/components/case/summaryTypes/pinswg_harbourrevisionorderid.js b/components/case/summaryTypes/pinswg_harbourrevisionorderid.js index a52a9631..29c480fd 100644 --- a/components/case/summaryTypes/pinswg_harbourrevisionorderid.js +++ b/components/case/summaryTypes/pinswg_harbourrevisionorderid.js @@ -7,6 +7,7 @@ import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; import { hasOwn } from "../../utils"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const Pinswg_harbourrevisionorderid = (props) => { let { t } = useTranslation(); @@ -67,25 +68,16 @@ const Pinswg_harbourrevisionorderid = (props) => { label={t( "case:summary-case-type-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> { label={t( "case:summary-eia-required-label" )} - value={ - router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-to-be-confirmed-label" - ) - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + })} />
@@ -131,9 +116,6 @@ const Pinswg_harbourrevisionorderid = (props) => { )}
- {" "} - {/* {casesObj.caseDetails.caseOfficer || - ""} */} {hasOwn(casesObj, "_ownerid_value") ? casesObj[ "_ownerid_value@OData.Community.Display.V1.FormattedValue" @@ -145,75 +127,43 @@ const Pinswg_harbourrevisionorderid = (props) => { label={t( "case:summary-procedure-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] || "" - } + value={resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: "" + })} />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{casesObj.numberofchildincidents > 0 && ( @@ -262,21 +212,14 @@ const Pinswg_harbourrevisionorderid = (props) => { label={t( "case:summary-case-recommendation-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj.pinswg_recommendation + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj.pinswg_recommendation || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_recommendation, + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> {detailsObj.pinswg_webaddress != null && ( {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -192,7 +138,9 @@ const Pinswg_hedgeshedgerowstreepreservatioid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -224,26 +172,12 @@ const Pinswg_hedgeshedgerowstreepreservatioid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -281,7 +215,10 @@ const Pinswg_hedgeshedgerowstreepreservatioid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -352,7 +289,10 @@ const Pinswg_hedgeshedgerowstreepreservatioid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -365,27 +305,7 @@ const Pinswg_hedgeshedgerowstreepreservatioid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -152,7 +112,9 @@ const Pinswg_householderappealhasid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -216,7 +178,10 @@ const Pinswg_householderappealhasid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) diff --git a/components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js b/components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js index a122a386..7b555265 100644 --- a/components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js +++ b/components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -24,23 +24,16 @@ const Pinswg_lawfuldevelopmentcertificatappid = (props) => {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +121,9 @@ const Pinswg_lawfuldevelopmentcertificatappid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +187,10 @@ const Pinswg_lawfuldevelopmentcertificatappid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +261,10 @@ const Pinswg_lawfuldevelopmentcertificatappid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -319,27 +277,7 @@ const Pinswg_lawfuldevelopmentcertificatappid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -154,7 +111,9 @@ const Pinswg_ldpid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -218,7 +177,10 @@ const Pinswg_ldpid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -289,7 +251,10 @@ const Pinswg_ldpid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -302,27 +267,7 @@ const Pinswg_ldpid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_listedbuildingandconservationrid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_listedbuildingandconservationrid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_listedbuildingandconservationrid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -319,27 +279,7 @@ const Pinswg_listedbuildingandconservationrid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_maintenanceoflands217id = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_maintenanceoflands217id = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_maintenanceoflands217id = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) diff --git a/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js b/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js index 40be3302..c447c0bd 100644 --- a/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js +++ b/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -24,23 +24,16 @@ const Pinswg_miscellaneouscasewordid = (props) => {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_miscellaneouscasewordid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -203,26 +157,12 @@ const Pinswg_miscellaneouscasewordid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -260,7 +200,10 @@ const Pinswg_miscellaneouscasewordid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -331,7 +274,10 @@ const Pinswg_miscellaneouscasewordid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) diff --git a/components/case/summaryTypes/pinswg_nonvalidationid.js b/components/case/summaryTypes/pinswg_nonvalidationid.js index 24674a1c..e653d467 100644 --- a/components/case/summaryTypes/pinswg_nonvalidationid.js +++ b/components/case/summaryTypes/pinswg_nonvalidationid.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; @@ -24,23 +24,16 @@ const Pinswg_nonvalidationid = (props) => {
{
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decisionissued@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decisionissued@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decisionissued@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
diff --git a/components/case/summaryTypes/pinswg_planningappeals78id.js b/components/case/summaryTypes/pinswg_planningappeals78id.js index a0013d87..5c297b61 100644 --- a/components/case/summaryTypes/pinswg_planningappeals78id.js +++ b/components/case/summaryTypes/pinswg_planningappeals78id.js @@ -1,8 +1,8 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import pickListLookup from "../../../data/picklistLookups.json"; import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { @@ -10,6 +10,7 @@ import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; import { hasOwn } from "../../utils"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const Pinswg_planningappeals78id = (props) => { let { t } = useTranslation(); @@ -27,23 +28,16 @@ const Pinswg_planningappeals78id = (props) => {
{ } /> + + +
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_dicision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_dicision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_dicision@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{ } /> - {/* */} - { : t("case:summary-no-date-entered-label") } /> - {/* */} - {/* */} {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_planningconditionss73s79id = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_planningconditionss73s79id = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_planningconditionss73s79id = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -319,29 +279,7 @@ const Pinswg_planningconditionss73s79id = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_planningobligationappeals106id = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -235,7 +189,10 @@ const Pinswg_planningobligationappeals106id = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -306,7 +263,10 @@ const Pinswg_planningobligationappeals106id = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) diff --git a/components/case/summaryTypes/pinswg_rowid.js b/components/case/summaryTypes/pinswg_rowid.js index f4ca69ac..ea706fec 100644 --- a/components/case/summaryTypes/pinswg_rowid.js +++ b/components/case/summaryTypes/pinswg_rowid.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; @@ -7,6 +6,7 @@ import SummaryCard from "../summary/components/SummaryCard"; import SummaryRow from "../summary/components/SummaryRow"; import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue"; import { hasOwn } from "../../utils"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const Pinswg_rowid = (props) => { let { t } = useTranslation(); @@ -24,43 +24,30 @@ const Pinswg_rowid = (props) => {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
{casesObj.numberofchildincidents > 0 && ( @@ -192,7 +136,9 @@ const Pinswg_rowid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -224,26 +170,12 @@ const Pinswg_rowid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -281,7 +213,10 @@ const Pinswg_rowid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -352,7 +287,10 @@ const Pinswg_rowid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -365,27 +303,7 @@ const Pinswg_rowid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + { )[0] : ""}

- - {/*

- {detailsObj.pinswg_projectlocation != null - ? detailsObj.pinswg_projectlocation.indexOf( - ";" - ) < 0 - ? detailsObj.pinswg_projectlocation - : router.locale == "cy" - ? detailsObj.pinswg_projectlocation.split( - ";" - )[1] - : detailsObj.pinswg_projectlocation.split( - ";" - )[0] - : ""} -

*/} @@ -106,23 +91,16 @@ const Pinswg_sipscase = (props) => { label={t( "case:summary-case-type-label" )} - value={ - router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> {projectTypes.length > 0 && ( @@ -200,12 +178,7 @@ const Pinswg_sipscase = (props) => { } /> )} - {/*
-
- Project Type -
-
- */} + { value={ detailsObj.pinswg_choiceofprocedure !== null - ? router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue" - ] + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + }) : t( "case:summary-to-be-confirmed-label" ) @@ -250,18 +221,16 @@ const Pinswg_sipscase = (props) => { value={ detailsObj.pinswg_essubmitted !== null - ? router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_essubmitted@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_essubmitted@OData.Community.Display.V1.FormattedValue" - ] + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-to-be-confirmed-label" + ) + }) : t( "case:summary-to-be-confirmed-label" ) @@ -274,157 +243,41 @@ const Pinswg_sipscase = (props) => { value={ detailsObj.pinswg_deemedmarinelicenseappliedfor !== null - ? router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_deemedmarinelicenseappliedfor@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_deemedmarinelicenseappliedfor@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-to-be-confirmed-label" - ) - } - /> - {/* */} - {/* */} - {/* - - - /> */}
{t("case:summary-decision-label")}
{detailsObj.pinswg_decision !== null - ? router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + }) : t( "case:summary-no-information-to-date-label" )} - -
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{ ) : ( "" )} - {/* */}
@@ -925,671 +762,6 @@ const Pinswg_sipscase = (props) => {
)} - - {/*
-

- EIA Screening -

- -
- - - - {hasValidKey( - detailsObj, - "pinswg_targetextended" - ) && ( - - )} - - - {hasValidKey( - detailsObj, - "pinswg_eiarequired" - ) && ( - - )} -
-
*/} - {/*
-

- EIA Scoping -

- -
- - - {hasValidKey( - detailsObj, - "pinswg_scopingtargetextended" - ) && ( - - )} - -
-
*/} - {/*
- - {hasOwn( - detailsObj, - "pinswg_applicationacceptedasvalid" - ) && - !_.isEmpty( - detailsObj.pinswg_applicationrejectedasinvalid - ) && ( - - )} - {hasOwn( - detailsObj, - "pinswg_applicationrejectedasinvalid" - ) && - !_.isEmpty( - detailsObj.pinswg_applicationrejectedasinvalid - ) && ( - - )} - - - {hasOwn( - detailsObj, - "pinswg_dateofrequesttovarytheapplication" - ) && - !_.isEmpty( - detailsObj.pinswg_dateofrequesttovarytheapplication - ) && ( - - )} - - {hasOwn( - detailsObj, - "pinswg_confirmrequesttovaryapplication" - ) && - !_.isEmpty( - detailsObj.pinswg_confirmrequesttovaryapplication - ) && - (hasOwn( - detailsObj, - "pinswg_rejectrequesttovaryapplication" - ) && - _.isEmpty( - detailsObj.pinswg_rejectrequesttovaryapplication - ) ? ( - - ) : ( - "" - ))} - {hasOwn( - detailsObj, - "pinswg_rejectrequesttovaryapplication" - ) && - !_.isEmpty( - detailsObj.pinswg_rejectrequesttovaryapplication - ) && - (hasOwn( - detailsObj, - "pinswg_confirmrequesttovaryapplication" - ) && - _.isEmpty( - detailsObj.pinswg_confirmrequesttovaryapplication - ) ? ( - - ) : ( - "" - ))} - {hasOwn( - detailsObj, - "pinswg_suspensionstartdates" - ) && - !_.isEmpty( - detailsObj.pinswg_suspensionstartdates - ) && ( - - )} - - - - - - {hasOwn( - detailsObj, - "pinswg_withdrawndate" - ) && - !_.isEmpty( - detailsObj.pinswg_withdrawndate - ) && ( - - )} -
*/} diff --git a/components/case/summaryTypes/pinswg_transportandworkactid.js b/components/case/summaryTypes/pinswg_transportandworkactid.js index 9c1b417d..50c05034 100644 --- a/components/case/summaryTypes/pinswg_transportandworkactid.js +++ b/components/case/summaryTypes/pinswg_transportandworkactid.js @@ -66,68 +66,43 @@ const Pinswg_transportandworkactid = (props) => { label={t( "case:summary-case-type-label" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - ) - } + value={resolveCrmDisplayValue({ + value: casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-date-entered-label" + ) + })} /> {detailsObj.pinswg_webaddress != null && ( {
{ />
{t("case:summary-decision-label")}
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup, + fallbackValue: t( + "case:summary-no-information-to-date-label" + ) + })}
- {/* - - {casesObj.caseDetails - .outcome_document || ""} - - */}
{casesObj.numberofchildincidents > 0 && ( @@ -171,7 +123,9 @@ const Pinswg_wayleaveid = (props) => { {t("case:summary-case-link-status-label")}
- {hasOwn(casesObj, ["numberofchildincidents"]) + {hasOwn(casesObj, [ + "numberofchildincidents" + ]) ? casesObj.numberofchildincidents > 0 ? t( "case:summary-case-link-status-linked" @@ -203,26 +157,12 @@ const Pinswg_wayleaveid = (props) => { label={t( "case:summary-case-relevant-authoritylabel" )} - value={ - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_lpa=="' + - detailsObj.pinswg_relevantauthorityname + - '")].value', - json: transLookup, - eval: true - }) || - t("case:summary-no-date-entered-label") - } + value={resolveCrmDisplayValue({ + value: detailsObj.pinswg_relevantauthorityname, + locale: router.locale, + translations: transLookup, + fallbackValue: "" + })} />
@@ -260,7 +200,10 @@ const Pinswg_wayleaveid = (props) => { "case:summary-questionnaire-due-date-label" )} value={ - hasOwn(detailsObj, "pinswg_questionnaireduedate") + hasOwn( + detailsObj, + "pinswg_questionnaireduedate" + ) ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) @@ -331,7 +274,10 @@ const Pinswg_wayleaveid = (props) => { "case:summary-applicant-final-comments-date-label" )} value={ - hasOwn(detailsObj, "pinswg_finalcommentsduedate") + hasOwn( + detailsObj, + "pinswg_finalcommentsduedate" + ) ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) @@ -344,27 +290,7 @@ const Pinswg_wayleaveid = (props) => { : t("case:summary-no-date-entered-label") } /> - {/* */} + { const { showFileUpload, showLoginCheck, docsOffline } = props; @@ -38,78 +39,17 @@ const MyPortal = (props) => { return ( <>
- {/*
-

- { -

- -
- {router.locale{" "} -
- - {props.accountDetails.accountDetails.firstname}{" "} - {props.accountDetails.accountDetails.lastname} - {" - "} - { - props.accountDetails.accountDetails[ - "pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue" - ] - } - -
-
- { - handleLogout(); - }} - className="govuk-header__link " - > - {t("common:signout-label")} - -
-
-
*/} {isLPA && (

- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - props.accountDetails.accountDetails[ - "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : props.accountDetails.accountDetails[ - "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" - ]}{" "} + {resolveCrmDisplayValue({ + value: props.accountDetails.accountDetails[ + "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}{" "} {t("myportal:lpa-portal-heading")}

@@ -121,18 +61,9 @@ const MyPortal = (props) => { {!isLPA && ( )} - {/* {props.awaitingSubmission.awaitingSubmission[ - "@odata.count" - ] > 0 && ( - - )} */} {!isLPA && - hasOwnhas(props.awaitingSubmission, [ + _.has(props.awaitingSubmission, [ "awaitingSubmissionFromBlob", "@odata.count" ]) && diff --git a/components/myportal/advancedsearch.js b/components/myportal/advancedsearch.js index 7e52a6ca..210acbce 100644 --- a/components/myportal/advancedsearch.js +++ b/components/myportal/advancedsearch.js @@ -1,10 +1,10 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { Field, formValueSelector, reduxForm } from "redux-form"; import transLookup from "../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const required = (errorMsg) => (value) => value || typeof value === "number" ? undefined : errorMsg; @@ -133,22 +133,11 @@ let AdvancedSearch = (props) => { key={key} value={optionsObj[key].accountid} > - {/* {optionsObj[key].name} */} - - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - optionsObj[key] - .name + - '")].value_cy', - json: transLookup, - eval: true - }) - : optionsObj[key].name || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: optionsObj[key].name, + locale, + translations: transLookup + })} ); })} @@ -234,31 +223,11 @@ let AdvancedSearch = (props) => { .toLowerCase() } > - {_.isEmpty(optionsObj[key]) - ? "" - : _.isEmpty(optionsObj[key]) - ? "" - : _.isEmpty( - optionsObj[key] - .value - ) - ? "" - : router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - optionsObj[ - key - ].value + - '")].value_cy', - json: transLookup, - eval: true - }) - : optionsObj[key] - .value || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: optionsObj[key].value, + locale, + translations: transLookup + })} ); })} diff --git a/components/myportal/awaitingsubmissionfromblob.js b/components/myportal/awaitingsubmissionfromblob.js index c6a05dda..8ea4055e 100644 --- a/components/myportal/awaitingsubmissionfromblob.js +++ b/components/myportal/awaitingsubmissionfromblob.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -18,6 +17,7 @@ import { setCurrentReference, setCurrentView } from "../../store/currentView/action"; +import { resolveCrmDisplayValue } from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const AwaitingSubmissionFromBlob = (props) => { let { t } = useTranslation(); @@ -201,22 +201,14 @@ const AwaitingSubmissionFromBlob = (props) => {
{t("myportal:appeal-type-label")}:{" "} - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - getFormCollectionByID( - showTopThreeArr[key] - .pinswg_appealcasetype - ).value + - '")].value_cy', - json: transLookup, - eval: true - }) - : getFormCollectionByID( - showTopThreeArr[key] - .pinswg_appealcasetype - ).value || ""} + {resolveCrmDisplayValue({ + value: getFormCollectionByID( + showTopThreeArr[key] + .pinswg_appealcasetype + ).value, + locale, + translations: transLookup + })}
{t("myportal:case-address")}:{" "} @@ -302,20 +294,14 @@ const AwaitingSubmissionFromBlob = (props) => { {router.locale == "cy" ? "ACLl" : "LPA"} : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key][ - "pinswg_lpaname" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : showTopThreeArr[key][ - "pinswg_lpaname" - ] || ""} + + {resolveCrmDisplayValue({ + value: showTopThreeArr[key][ + "pinswg_lpaname" + ], + locale, + translations: transLookup + })}
{t("myportal:date-raised")}: diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index 91c0a10c..bc8fe812 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; @@ -33,6 +32,7 @@ import { planningappeals78_pdf } from "../../components/pdftemplates/planningapp import { other_pdf } from "../../components/pdftemplates/other_pdf"; import { PDFDownloadLink, pdf } from "@react-pdf/renderer"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const TopThree = (props) => { let { t } = useTranslation(); @@ -406,20 +406,13 @@ const TopThree = (props) => {
{t("myportal:appeal-type-label")}:{" "} - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key][ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : showTopThreeArr[key][ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || ""} + {resolveCrmDisplayValue({ + value: showTopThreeArr[key][ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}
{/* )} */} {/* {topThreeType != "awaitingSubmission" ? ( */} @@ -484,20 +477,13 @@ const TopThree = (props) => { )}
{router.locale == "cy" ? "ACLl" : "LPA"}: - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key][ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : showTopThreeArr[key][ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || ""} + {resolveCrmDisplayValue({ + value: showTopThreeArr[key][ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}
{topThreeType == "awaitingSubmission" ? (
diff --git a/components/myportal/topthree_reps.js b/components/myportal/topthree_reps.js index 40c3ab99..2d11eb9a 100644 --- a/components/myportal/topthree_reps.js +++ b/components/myportal/topthree_reps.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -34,6 +33,7 @@ import { setWatchedCasesDetails } from "../../store/watchedCases/action"; import { getFormCollectionByID, getDetailsProxy } from "../utils"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const TopThree = (props) => { let { t } = useTranslation(); @@ -196,19 +196,6 @@ const TopThree = (props) => { {showTopThreeArr[key].pinswg_name} ) : ( {
{t("myportal:representation-type")}: - {" "} - - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key].representationType + - '")].value_cy', - json: transLookup, - eval: true - }) - : showTopThreeArr[key].representationType || ""} + {resolveCrmDisplayValue({ + value: showTopThreeArr[key].representationType, + locale, + translations: transLookup + })}
{t("myportal:capacity")}: - {" "} - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key] - .representationCapacity + - '" ||@.value_cy=="' + - showTopThreeArr[key] - .representationCapacity + - '" )].value_cy', - json: transLookup, - eval: true - }) - : jsonpath({ - path: - '$..[?(@ && @.value_cy=="' + - showTopThreeArr[key] - .representationCapacity + - '")].value', - json: transLookup, - eval: true - }).length > 0 - ? jsonpath({ - path: - '$..[?(@ && @.value_cy=="' + - showTopThreeArr[key] - .representationCapacity + - '")].value', - json: transLookup, - eval: true - }) - : showTopThreeArr[key].representationCapacity} + {resolveCrmDisplayValue({ + value: showTopThreeArr[key].representationCapacity, + locale, + translations: transLookup + })}
{t("myportal:date-raised")}: @@ -348,22 +300,13 @@ const TopThree = (props) => {
{" "}
{router.locale == "cy" ? "ACLl" : "LPA"}: - {" "} - - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - showTopThreeArr[key][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : showTopThreeArr[key][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] || ""} + {resolveCrmDisplayValue({ + value: showTopThreeArr[key][ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ], + locale, + translations: transLookup + })}
{showTopThreeArr[key].hasOwnProperty("repComplete") && (
diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index 15af643e..12b9c1ec 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -46,6 +46,7 @@ import { setMyRepresentations, setMyRepresentationsDetails } from "../../store/myRepresentations/action"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const ViewAllResults = (props) => { const { @@ -493,86 +494,66 @@ const ViewAllResults = (props) => { {isAwaitingSubmissionDetails && hasOwn(resultItem, "pinswg_lpaname") - ? router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - resultItem.pinswg_lpaname + - '")].value_cy', - json: transLookup, - eval: true - }) - : resultItem.pinswg_lpaname || "N/A" + ? resolveCrmDisplayValue({ + value: resultItem.pinswg_lpaname, + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""} {hasOwn(resultItem, [ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ]) - ? router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - resultItem[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : resultItem[ + ? resolveCrmDisplayValue({ + value: resultItem[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""} {hasOwn(searchDetailsObj[key], [ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" ]) - ? router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - (searchDetailsObj[key][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] || - searchDetailsObj[key]?.value[0][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ]) + - '")].value_cy', - json: transLookup, - eval: true - }) - : isMyRepresentations - ? searchDetailsObj[key].value - : searchDetailsObj[key].value[0][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ? resolveCrmDisplayValue({ + value: + searchDetailsObj[key][ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ] || + searchDetailsObj[key]?.value[0][ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: isMyRepresentations + ? searchDetailsObj[key].value + : searchDetailsObj[key].value[0][ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ] || "N/A" + }) : ""} {hasOwn(resultItem, [ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" ]) - ? router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - resultItem[ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : resultItem[ + ? resolveCrmDisplayValue({ + value: resultItem[ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] || (isMyRepresentations ? "" : "N/A") + ], + locale: router.locale, + translations: transLookup, + fallbackValue: isMyRepresentations + ? "" + : "N/A" + }) : isMyRepresentations && router.locale === "cy" && - jsonpath({ - path: - '$..[?(@ && @.value=="' + - searchDetailsObj[key][ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true + resolveCrmDisplayValue({ + value: searchDetailsObj[key][ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup })}
@@ -581,50 +562,36 @@ const ViewAllResults = (props) => { {isAwaitingSubmissionDetails - ? router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - getFormCollectionByID( - item.pinswg_appealcasetype - ).value + - '")].value_cy', - json: transLookup, - eval: true - }) - : getFormCollectionByID( + ? resolveCrmDisplayValue({ + value: getFormCollectionByID( item.pinswg_appealcasetype - ).value || "N/A" - : router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || (isMyRepresentations ? "" : "N/A")} + ).value, + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) + : resolveCrmDisplayValue({ + value: item[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: isMyRepresentations + ? "" + : "N/A" + })} {isMyRepresentations && - (router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - getFormCollectionByID( - searchDetailsObj[key].appealType - ).value + - '")].value_cy', - json: transLookup, - eval: true - })[0] - : getFormCollectionByID( - searchDetailsObj[key].appealType - ).value)} + resolveCrmDisplayValue({ + value: getFormCollectionByID( + searchDetailsObj[key].appealType + ).value, + locale: router.locale, + translations: transLookup, + fallbackValue: getFormCollectionByID( + searchDetailsObj[key].appealType + ).value + })} {hasOwn( searchDetailsObj[key], "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" @@ -658,41 +625,14 @@ const ViewAllResults = (props) => { }) || "N/A" : isMyRepresentations ? repRaisedDate(item.repfile_name) // ? router.locale == "cy" - : // ? jsonpath({path: - // - // '$..[?(@ && @.value=="' + - // searchDetailsObj[key].value[0][ - // "statuscode@OData.Community.Display.V1.FormattedValue" - // ] + - // '")].value_cy',transLookup, - // ) - // : searchDetailsObj[key].value[0][ - // "statuscode@OData.Community.Display.V1.FormattedValue" - // ] || "N/A" - // : router.locale == "cy" - // ? jsonpath({path: - // - // '$..[?(@ && @.value=="' + - // item[ - // "statuscode@OData.Community.Display.V1.FormattedValue" - // ] + - // '")].value_cy',transLookup, - // ) - - router.locale === "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + : resolveCrmDisplayValue({ + value: item[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
{isAwaitingSubmissionDetails && (
diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 7925320f..a23d6e0e 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -24,6 +24,7 @@ import { selectRowFieldType, selectRowLabelDescriptions } from "../../lib/newappeal/formDerivation"; +import { resolveCrmDisplayValue } from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; let BuildCheckRow = (props) => { let { t } = useTranslation(); @@ -74,14 +75,12 @@ let BuildCheckRow = (props) => { eval: true }); - let labelTrans = - router.locale == "cy" - ? jsonpath({ - path: '$..[?(@ && @.value=="' + label + '")].value_cy', - json: formObj, - eval: true - }) - : label; + let labelTrans = resolveCrmDisplayValue({ + value: label, + locale, + translations: formObj + }); + return labelTrans; }; diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js index a80c7439..2ebda3eb 100644 --- a/components/newappeal/buildchecksection.js +++ b/components/newappeal/buildchecksection.js @@ -32,6 +32,7 @@ import DocsOfflineNotice from "./buildCheckSection/DocsOfflineNotice"; import FinalisingStatePanel from "./buildCheckSection/FinalisingStatePanel"; import SectionReviewList from "./buildCheckSection/SectionReviewList"; import SubmitActionsPanel from "./buildCheckSection/SubmitActionsPanel"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; let BuildCheckSection = (props) => { useEffect(() => { @@ -144,14 +145,11 @@ let BuildCheckSection = (props) => { eval: true }); - let labelTrans = - router.locale == "cy" - ? jsonpath({ - path: '$..[?(@ && @.value=="' + label + '")].value_cy', - json: formObj, - eval: true - }) - : label; + let labelTrans = resolveCrmDisplayValue({ + value: label, + locale, + translations: formObj + }); return labelTrans; }; diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index 390a1ab4..c7e60792 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { useState } from "react"; @@ -15,6 +14,7 @@ import { } from "../../store/appealType/action"; import { getFormCollectionByID, hasOwn } from "../utils"; import Aboutyou from "./aboutyou"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const RenderLPAList = ({ name, @@ -52,32 +52,29 @@ const RenderLPAList = ({ className="govuk-select govuk-input--error" id="lpatypes" name="lpatypes" - //onChange={(e) => props.onChangeSelectLPA(e)} > - {_.isEmpty(optionsObj) - ? "" - : Object.keys(optionsObj).map((key, index) => { - return ( - - ); - })} + + {Object.keys(optionsObj || {}).map((key) => { + const option = optionsObj[key]; + + return ( + + ); + })} @@ -119,53 +116,33 @@ const RenderAppealTypeList = ({ className="govuk-select" id="appealTypes" name={name} - //onChange={(e) => props.onChangeSelectAppealType(e)} > - {_.isEmpty(optionsObj) - ? "" - : Object.keys(optionsObj).map((key, index) => { - return ( - - ); - })} + + {Object.keys(optionsObj || {}).map((key) => { + const option = optionsObj[key]; + + return ( + + ); + })} @@ -305,25 +282,11 @@ function Radiofield(props) { .slice(1, props.options.length - 1) .split(","); - //parentFieldShowOnValue var showIfHasParentShowValue = parentField != false; - //debugger; - // parentField != false && - // !_.isEmpty(formProps[form]) && - // hasOwn(formProps[form].values, parentField) && - // parentFieldShowOnValue.indexOf( - // formProps[form].values[parentField].toString() - // ) > -1; (showIfHasParentShowValue == parentField) != false && showIfHasParentShowValue; - //console.log( - // datafieldname, - // showIfHasParentShowValue, - // formProps[form].values[parentField] - // ); - return ( <> {parentField != false ? ( @@ -466,20 +429,6 @@ let CreateCase = (props) => { .catch((error) => { consoleLogger(error); }); - - // router.replace( - // "/newappeal" + - // "/" + - // appTypeCollection.UrlName + - // "?lpa=" + - // values.lpaTypes + - // "&apt=" + - // values.appealTypes.split(",")[0], - // null, - // { - // shallow: true, - // } - // ); }; const yesNo = isWelsh ? ["Ydw", "Na"] : ["Yes", "No"]; @@ -488,13 +437,13 @@ let CreateCase = (props) => { form = "caseForm", parentFieldShowOnValue = "846040004"; - var showIfHasParentShowValue = - parentField != false && - !_.isEmpty(formProps[form]) && - hasOwn(formProps[form].values, parentField) && - parentFieldShowOnValue.indexOf( - formProps[form].values[parentField].toString() - ) > -1; + const values = formProps[form]?.values; + + const showIfHasParentShowValue = + parentField !== false && + values && + hasOwn(values, parentField) && + parentFieldShowOnValue.includes(values[parentField].toString()); (showIfHasParentShowValue == parentField) != false && showIfHasParentShowValue; diff --git a/components/pdftemplates/appealRow_pdf.js b/components/pdftemplates/appealRow_pdf.js index 6e97ad6e..6c8cbe30 100644 --- a/components/pdftemplates/appealRow_pdf.js +++ b/components/pdftemplates/appealRow_pdf.js @@ -14,6 +14,7 @@ import Html from "react-pdf-html"; import { DOMParser, XMLSerializer } from "@xmldom/xmldom"; import transLookup from "../../data/lookuptranslations.json"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; export const AppealRow_pdf = (props) => { let { t } = useTranslation(); @@ -435,32 +436,18 @@ export const AppealRow_pdf = (props) => { )} - {locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - getPickListLabel( - props.pickListData, - datafieldname[0] - .value, - props.props[ - datafieldname[0] - .value - ] - ) + - '")].value_cy', - json: transLookup, - eval: true - }) - : getPickListLabel( - props.pickListData, - datafieldname[0] - .value, - props.props[ - datafieldname[0] - .value - ] - )} + {resolveCrmDisplayValue({ + value: getPickListLabel( + props.pickListData, + datafieldname[0].value, + props.props[ + datafieldname[0] + .value + ] + ), + locale, + translations: transLookup + })} ); diff --git a/components/pdftemplates/planningappeals78_pdf.js b/components/pdftemplates/planningappeals78_pdf.js index 3cd323de..9ef70d6f 100644 --- a/components/pdftemplates/planningappeals78_pdf.js +++ b/components/pdftemplates/planningappeals78_pdf.js @@ -22,6 +22,7 @@ import transLookupEN from "../../locales/en/newappeal.json"; import transLookup from "../../data/lookuptranslations.json"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import { JSONPath as jsonpath } from "jsonpath-plus"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const getTrans = (locale, key) => { let jsonQuery = `$.${key}`; @@ -666,22 +667,12 @@ export const planningappeals78_pdf = ({ docProps, pickListData }) => { )} - {/* {values.caseObj.pinswg_lpaname || - values.caseObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ]} */} - - {locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - values.caseObj - .pinswg_lpaname + - '")].value_cy', - json: transLookup, - eval: true - }) - : values.caseObj.pinswg_lpaname} + {resolveCrmDisplayValue({ + value: values.caseObj + .pinswg_lpaname, + locale, + translations: transLookup + })} {/* { item, "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" ) - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ + ? resolveCrmDisplayValue({ + value: item[ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""} {hasOwn( item, "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ) - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ + ? resolveCrmDisplayValue({ + value: item[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""} {item?.pinswg_lpareference && ( <> @@ -653,19 +642,12 @@ const SearchResults = (props) => { )} : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "pinswg_appealType" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item["pinswg_appealType"] || - "N/A"} + {resolveCrmDisplayValue({ + value: item["pinswg_appealType"], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
@@ -675,20 +657,14 @@ const SearchResults = (props) => { : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
{myportal == true && (
diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js index ab561094..908e2837 100644 --- a/components/search/advancedsearch.js +++ b/components/search/advancedsearch.js @@ -1,4 +1,3 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; @@ -7,6 +6,7 @@ import { useEffect, useState } from "react"; import transLookup from "../../data/lookuptranslations.json"; import { getCaseStatus } from "../../actions/services/caseDirectService"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const required = (errorMsg) => (value) => value || typeof value === "number" ? undefined : errorMsg; @@ -282,22 +282,11 @@ let AdvancedSearch = (props) => { key={key} value={optionsObj[key].accountid} > - {/* {optionsObj[key].name} */} - - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - optionsObj[key] - .name + - '")].value_cy', - json: transLookup, - eval: true - }) - : optionsObj[key].name || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: optionsObj[key].name, + locale, + translations: transLookup + })} ); })} @@ -383,31 +372,11 @@ let AdvancedSearch = (props) => { .toLowerCase() } > - {_.isEmpty(optionsObj[key]) - ? "" - : _.isEmpty(optionsObj[key]) - ? "" - : _.isEmpty( - optionsObj[key] - .value - ) - ? "" - : router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - optionsObj[ - key - ].value + - '")].value_cy', - json: transLookup, - eval: true - }) - : optionsObj[key] - .value || - t( - "case:summary-no-date-entered-label" - )} + {resolveCrmDisplayValue({ + value: optionsObj[key].value, + locale, + translations: transLookup + })} ); })} @@ -456,69 +425,47 @@ let AdvancedSearch = (props) => { className="govuk-select" id={id} name={name} - //onChange={(e) => props.onChangeSelectAppealType(e)} > - {_.isEmpty(optionsObj) - ? "" - : Object.keys(optionsObj).map((key, index) => { - return ( - - ); - })} + + {Object.keys(optionsObj || {}).map((key) => { + const option = optionsObj[key]; + const projectTypeId = + option?.pinswg_sipsprojecttypeid; + const projectName = option?.pinswg_name; + + const cleanProjectName = projectName + ? projectName + .replace( + /(\band|[\s\-\+\(\),&])/g, + "" + ) + .toLowerCase() + : ""; + + return ( + + ); + })} @@ -595,7 +542,6 @@ let AdvancedSearch = (props) => { {t("search:search-title-label")} - { "myportal:searchcases-card-search-example-label-2" )} /> - { "myportal:searchcases-card-search-example-label-2" )} /> - { label={t("search:appealtype-label")} errormsg="Appeal type is required" /> - {props.appealTypesValue?.split( "," )[0] === "846040002" && ( diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js index 25095bfe..9b1ce4b4 100644 --- a/components/search/dnssearchresults.js +++ b/components/search/dnssearchresults.js @@ -22,6 +22,7 @@ import { deleteWatchedCases, getWatchedCasesProxy } from "../../actions/services/portalService"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import { setCurrentPage, setCurrentReference @@ -394,21 +395,14 @@ const DNSSearchResults = (props) => { }); detailsObj = detailsObj[0]; - var appType = - router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@.value=="' + - item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || "N/A"; + var appType = resolveCrmDisplayValue({ + value: item[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }); appType = appType == @@ -609,20 +603,14 @@ const DNSSearchResults = (props) => { detailsObj, "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ) - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ + ? resolveCrmDisplayValue({ + value: detailsObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""}
@@ -632,20 +620,14 @@ const DNSSearchResults = (props) => { )} : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
diff --git a/components/search/searchresults.js b/components/search/searchresults.js index 12e2a76f..b807e46b 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -35,6 +35,7 @@ import { deleteWatchedCases, getWatchedCasesProxy } from "../../actions/services/portalService"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; import { sendGAEvent } from "@next/third-parties/google"; import RepsOnResults from "./repsonresults"; @@ -613,20 +614,14 @@ const SearchResults = (props) => { item, "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ) - ? router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ + ? resolveCrmDisplayValue({ + value: item[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || "N/A" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + }) : ""} {item?.pinswg_lpareference && ( <> @@ -649,39 +644,28 @@ const SearchResults = (props) => { )} : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })} {detailsObj?.pinswg_specialistcaseprocess && ( <>

- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_specialistcaseprocess@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true - }) - : detailsObj[ - "pinswg_specialistcaseprocess@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: detailsObj[ + "pinswg_specialistcaseprocess@OData.Community.Display.V1.FormattedValue" + ], + locale: router.locale, + translations: + transLookup, + fallbackValue: "N/A" + })} )} @@ -694,20 +678,14 @@ const SearchResults = (props) => { : - {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ].trim() + - '")].value_cy', - json: transLookup, - eval: true - }) - : item[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || "N/A"} + {resolveCrmDisplayValue({ + value: item[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ]?.trim(), + locale: router.locale, + translations: transLookup, + fallbackValue: "N/A" + })}
{myportal == true && (
diff --git a/components/utils/getCaseLpaDisplayValue.js b/components/utils/getCaseLpaDisplayValue.js index 027ef0e2..0aac8284 100644 --- a/components/utils/getCaseLpaDisplayValue.js +++ b/components/utils/getCaseLpaDisplayValue.js @@ -1,17 +1,15 @@ -import { JSONPath as jsonpath } from "jsonpath-plus"; +import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const translateLpaName = ({ name, locale, transLookup }) => { if (!name) return ""; if (locale !== "cy") return name; - return ( - jsonpath({ - path: '$..[?(@ && @.value=="' + name + '")].value_cy', - json: transLookup, - eval: true - })?.[0] || name - ); + return resolveCrmDisplayValue({ + value: name, + locale, + translations: transLookup + }); }; export const getCaseLpaNames = ({ diff --git a/context/architecture.md b/context/architecture.md index 250741a0..3676c67b 100644 --- a/context/architecture.md +++ b/context/architecture.md @@ -51,6 +51,55 @@ Business responsibility clarification: This architectural reference builds on those business concepts but does not replace the more detailed terminology guide in `context/business-domain-overview.md`. +## CRM Display Infrastructure Status (2026-07-01) + +### Stream status + +**CRM Display Infrastructure: COMPLETE** + +### Shared helper introduced + +- `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` + +### Helper contract + +The shared CRM display resolver should be understood as handling the standard CRM formatted/display-value translation concern only. + +Current contract: + +- missing CRM display value -> return `fallbackValue` +- English -> return CRM display value +- Welsh -> return translated value when available +- Welsh without translation -> return CRM display value + +### Architectural responsibility + +This helper centralises the standard CRM formatted/display-value translation pattern used across portal presentation surfaces. + +It should be treated as the shared compatibility seam for: + +- CRM formatted values +- CRM display values +- standard EN/CY display translation lookup +- existing consumer-specific absent-value fallback handling + +### Boundary exclusions + +The helper boundary intentionally excludes the following concerns: + +- keyed lookup translation +- project-type list translation +- hyperlink / website rendering +- mixed presentation rows +- lifecycle interpretation +- status interpretation +- post-decision interpretation +- other presentation-specific derived values + +These are separate architectural concerns and should not be folded into `resolveCrmDisplayValue(...)`. + +If future work is needed in those areas, it should introduce a separate abstraction rather than broadening the helper. + ## Portal API Platform Assessment Status (2026-06-20) ### Stream status diff --git a/context/implementation-governance.md b/context/implementation-governance.md index bf488d8f..82ad8920 100644 --- a/context/implementation-governance.md +++ b/context/implementation-governance.md @@ -148,6 +148,27 @@ The adoption target should be explicit, such as: Do not attempt mass adoption by default. +### CRM Display Infrastructure Rule + +When rendering a standard CRM formatted/display value: + +- `resolveCrmDisplayValue(...)` should be used. + +Developers should not introduce new inline JSONPath lookups for the standard CRM formatted/display-value translation pattern. + +If the translation concern does not match the helper boundary, it should be treated as a separate abstraction rather than extending the helper. + +This includes concerns such as: + +- keyed lookup translation +- list translation +- hyperlink / website rendering +- mixed presentation rows +- lifecycle interpretation +- status interpretation +- post-decision interpretation +- other derived presentation values + --- ## 4. Branching Governance diff --git a/context/maintainability-adoption-programme.md b/context/maintainability-adoption-programme.md index 3b8a1749..47da4539 100644 --- a/context/maintainability-adoption-programme.md +++ b/context/maintainability-adoption-programme.md @@ -190,10 +190,13 @@ Create a clearer single source of truth for CRM-driven bilingual display behavio #### Current Maturity -- characterized -- repeated dominant pattern identified -- several partial abstractions already present -- suitable for incremental implementation +- completed +- shared resolver introduced +- helper test coverage added +- helper contract verified and corrected +- compatible consumers adopted across admin, search, My Portal, and summary types +- stale JSONPath import cleanup completed where safe +- behaviour-preserving migration completed #### Implementation Strategy @@ -202,6 +205,34 @@ Create a clearer single source of truth for CRM-driven bilingual display behavio - adopt first in bounded, read-only display families - preserve current fallback behaviour per consumer unless an explicit standardization decision is approved +#### Status + +Completed. + +Delivered in this workstream: + +- shared resolver introduced +- helper test coverage +- helper contract verified and corrected +- adoption across: + - admin + - search + - My Portal + - summary types +- stale JSONPath import cleanup +- behaviour-preserving migration + +Remaining JSONPath usage in adopted areas is intentional where it falls outside the helper boundary. + +That includes concerns such as: + +- keyed lookup translation +- project-type list translation +- hyperlink / website rendering +- mixed presentation rows +- lifecycle / status / post-decision interpretation +- other presentation-specific derived values + #### Expected Maintenance Benefit - reduced duplication of display-resolution logic diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 5a1e01cb..2b3efc3f 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -543,7 +543,7 @@ ], "pinswg_lpa": [ { - "value": "Isle of Anglesey County Council", + "value": "Anglesey County Council", "value_cy": "Cyngor Sir Ynys Môn", "pinswg_lpa": 846040000 }, @@ -1055,5 +1055,41 @@ "value": "Waste Water Treatment Plants", "value_cy": "Gweithfeydd Trin Dŵr Gwastraff" } + ], + "pinswg_specialistcaseprocess": [ + { + "value": "Advert (part 3)", + "value_cy": "Hysbyseb (rhan 3)" + }, + { + "value": "Advert (part 4)", + "value_cy": "Hysbyseb (rhan 4)" + }, + { + "value": "Hedgerows (Wreps & Hearings)", + "value_cy": "Gwrychoedd (Gwreiau a Gwrandawiadau" + }, + { + "value": "High Hedge Appeals (Wreps & Hearings)", + "value_cy": "Apelau Gwrychoedd Uchel (Gwreiau a Gwrandawiadau" + }, + { + "value": "TPO Appeals (Wreps)", + "value_cy": "Apelau Gorchymyn Diogelu Coed (Gwreiau)" + } + ], + "procedures": [ + { + "value": "Written representations", + "value_cy": "Sylwadau ysgrifenedig" + }, + { + "value": "Inquiry", + "value_cy": "Ymchwiliad" + }, + { + "value": "Hearing", + "value_cy": "Gwrandawiad" + } ] } \ No newline at end of file diff --git a/lib/i18n/crmDisplay/resolveCrmDisplayValue.js b/lib/i18n/crmDisplay/resolveCrmDisplayValue.js new file mode 100644 index 00000000..e00eb097 --- /dev/null +++ b/lib/i18n/crmDisplay/resolveCrmDisplayValue.js @@ -0,0 +1,29 @@ +import { JSONPath as jsonpath } from "jsonpath-plus"; + +const hasValue = (value) => + value !== null && value !== undefined && value !== ""; + +export const resolveCrmDisplayValue = ({ + value, + locale, + translations, + fallbackValue +}) => { + if (!hasValue(value)) { + return fallbackValue; + } + + if (locale !== "cy") { + return value; + } + + const matches = jsonpath({ + path: `$..[?(@ && @.value==${JSON.stringify(String(value))})].value_cy`, + json: translations, + eval: true + }); + + return matches[0] ?? value; +}; + +export default resolveCrmDisplayValue; diff --git a/locales/cy/case.json b/locales/cy/case.json index eeeb3695..27826595 100644 --- a/locales/cy/case.json +++ b/locales/cy/case.json @@ -152,5 +152,6 @@ "status-title": "Statws", "status-show-all-label": "Dangoswch bob cam", "status-hide-all-label": "Cuddio pob cam", - "project-type-label": "Math o brosiect" + "project-type-label": "Math o brosiect", + "summary-specialist-case-process-label": "Proses Achos Arbenigol" } \ No newline at end of file diff --git a/locales/en/case.json b/locales/en/case.json index e44fb460..344f7dc0 100644 --- a/locales/en/case.json +++ b/locales/en/case.json @@ -153,5 +153,6 @@ "status-title": "Status", "status-show-all-label": "Show all stages", "status-hide-all-label": "Hide all stages", - "project-type-label": "Project type" + "project-type-label": "Project type", + "summary-specialist-case-process-label": "Specialist Case Process" } \ No newline at end of file diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index 46dde422..255b73bd 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -18,6 +18,1525 @@ Follow-ups: --- +### CL-2026-07-01-CRM-DISPLAY-INFRASTRUCTURE-COMPLETION: document completed workstream and helper boundary + +date: 2026-07-01 +author: Cline +scope: `context/architecture.md`, `context/maintainability-adoption-programme.md`, `context/implementation-governance.md`, `memory-bank/change-log.md` +type: change +rationale: Record the completed CRM Display Infrastructure workstream in core architecture/programme/governance documentation so future contributors use the shared helper correctly and do not broaden it into separate presentation concerns. +impact: Documentation/governance only. Records the completed stream, final helper contract, preserved helper boundary, remaining intentional non-helper concerns, and future implementation guidance. No application code, tests, translations, routes, CRM queries, or runtime behaviour changed. +status: completed + +Summary: + +- Continued on branch: + - `feature/crm-display-resolver-slice1` +- Documented CRM Display Infrastructure as completed in: + - `context/architecture.md` + - `context/maintainability-adoption-programme.md` + - `context/implementation-governance.md` +- Recorded the shared helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Recorded the final helper contract: + - missing CRM display value -> return `fallbackValue` + - English -> return CRM display value + - Welsh -> return translated value when available + - Welsh without translation -> return CRM display value +- Recorded delivered workstream outcomes: + - shared resolver introduced + - helper test coverage + - helper contract verified and corrected + - compatible consumers migrated across admin, search, My Portal, and summary types + - stale JSONPath imports removed where safe + - behaviour-preserving migration completed +- Recorded architectural boundary exclusions that must remain separate from the helper: + - keyed lookup translation + - project-type list translation + - hyperlink / website rendering + - mixed presentation rows + - lifecycle interpretation + - status interpretation + - post-decision interpretation + - other presentation-specific derived values +- Recorded governance rule for future implementation: + - use `resolveCrmDisplayValue(...)` for the standard CRM formatted/display-value translation concern + - do not introduce new inline JSONPath lookups for that standard pattern + - introduce separate abstractions rather than broadening `resolveCrmDisplayValue(...)` + +Validation: + +- `git diff --check -- context/architecture.md context/maintainability-adoption-programme.md context/implementation-governance.md memory-bank/change-log.md` + +Follow-ups: + +- Future work should introduce separate abstractions rather than broadening `resolveCrmDisplayValue()`. + +### CL-2026-07-01-CRM-DISPLAY-RESOLVER-FALLBACK-CLEANUP: simplify remaining safe redundant fallbacks + +date: 2026-07-01 +author: Cline +scope: `components/case/summaryTypes/pinswg_callinss77id.js`, `components/myportal/viewall.js`, `memory-bank/change-log.md` +type: change +rationale: A final focused cleanup was requested to remove redundant `fallbackValue` patterns that repeated the same CRM display value already supplied as `value`, while preserving existing page-specific absent-value behaviour. +impact: Behaviour-preserving cleanup only. Simplified six redundant fallback patterns in `pinswg_callinss77id.js`. `components/myportal/viewall.js` was reviewed and left unchanged where remaining fallback scenarios were conditional or ambiguous. No helper logic, tests, search/admin files, routing, grouping, list logic, or derived value behaviour changed. +status: completed + +Summary: + +- Continued on branch: + - `feature/crm-display-resolver-slice1` +- Narrow scope followed exactly: + - edited only `components/case/summaryTypes/pinswg_callinss77id.js` + - reviewed `components/myportal/viewall.js` and left ambiguous fallback cases unchanged + - updated `memory-bank/change-log.md` +- Simplified six redundant fallback patterns in `pinswg_callinss77id.js`: + - case type -> `t("case:summary-no-date-entered-label")` + - EIA required -> `t("case:summary-to-be-confirmed-label")` + - procedure -> `""` + - type of event -> `""` + - status -> `t("case:summary-no-date-entered-label")` + - decision -> `t("case:summary-no-information-to-date-label")` +- Intentionally left unchanged in `components/myportal/viewall.js`: + - authority fallback using `searchDetailsObj[key].value` / nested `.value[0]` shape because the fallback source is conditional and structure-dependent + - case type fallback using `getFormCollectionByID(searchDetailsObj[key].appealType).value` in the `isMyRepresentations` branch because removing it could alter non-CRM derived display behaviour + +Validation: + +- Pending in current slice: + - `node tests/phase22/crm-display-resolver.test.cjs` + - eslint on touched files only + +Follow-ups: + +- If desired, the remaining `components/myportal/viewall.js` fallbacks should be handled in a separate characterization-first slice because they combine conditional view-specific data shapes with derived values. + +### CL-2026-07-01-CRM-DISPLAY-RESOLVER-STALE-JSONPATH-IMPORTS: remove stale JSONPath imports from adopted summaries + +date: 2026-07-01 +author: Cline +scope: `components/case/summaryTypes/pinswg_advertsid.js`, `components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js`, `components/case/summaryTypes/pinswg_environmentalpermittingid.js`, `components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js`, `components/case/summaryTypes/pinswg_maintenanceoflands217id.js`, `components/case/summaryTypes/pinswg_miscellaneouscasewordid.js`, `components/case/summaryTypes/pinswg_planningobligationappeals106id.js`, `components/case/summaryTypes/pinswg_wayleaveid.js`, `components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js`, `memory-bank/change-log.md` +type: change +rationale: Clean up stale `JSONPath` imports in already-adopted summary files where active `jsonpath(...)` usage no longer remains, without altering any runtime translation or rendering logic. +impact: Behaviour-preserving cleanup only. Removed unused `JSONPath as jsonpath` imports from nine adopted summary files. No helper logic, summary row behavior, fallback behavior, translation data, tests, routes, or linked-case logic changed. +status: completed + +Summary: + +- Continued on branch: + - `feature/crm-display-resolver-slice1` +- Narrowed cleanup scope followed exactly: + - only the fixed user-provided adopted summary file list was inspected + - only files with a stale `import { JSONPath as jsonpath } from "jsonpath-plus";` and no active `jsonpath(...)` call were edited +- Stale import removed from: + - `components/case/summaryTypes/pinswg_advertsid.js` + - `components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js` + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` + - `components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js` + - `components/case/summaryTypes/pinswg_maintenanceoflands217id.js` + - `components/case/summaryTypes/pinswg_miscellaneouscasewordid.js` + - `components/case/summaryTypes/pinswg_planningobligationappeals106id.js` + - `components/case/summaryTypes/pinswg_wayleaveid.js` + - `components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js` +- Intentionally left unchanged because they had no stale `JSONPath` import in the narrowed list: + - `pinswg_callinss77id.js` + - `pinswg_commonlandid.js` + - `pinswg_enforcementlistedbuildingconseid.js` + - `pinswg_enforcementnoticeappeals174id.js` + - `pinswg_householderappealhasid.js` + - `pinswg_ldpid.js` + - `pinswg_listedbuildingandconservationrid.js` + - `pinswg_nonvalidationid.js` + - `pinswg_planningconditionss73s79id.js` + - `pinswg_rowid.js` +- No runtime logic changed: + - no active `jsonpath(...)` branches were edited + - no helper calls or fallback values were changed + - no unrelated working-tree changes were touched + +Validation: + +- `CI=1 ./node_modules/.bin/eslint components/case/summaryTypes/pinswg_advertsid.js components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js components/case/summaryTypes/pinswg_environmentalpermittingid.js components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js components/case/summaryTypes/pinswg_maintenanceoflands217id.js components/case/summaryTypes/pinswg_miscellaneouscasewordid.js components/case/summaryTypes/pinswg_planningobligationappeals106id.js components/case/summaryTypes/pinswg_wayleaveid.js components/case/summaryTypes/pinswg_compulsorypurchaseordersid.js` + +Follow-ups: + +- Any further JSONPath cleanup should stay characterization-first and should only remove imports when active `jsonpath(...)` usage is absent in the exact target file. + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-BUGFIX: fix CRM display resolver fallback behaviour + +date: 2026-06-30 +author: Cline +scope: `tests/phase22/crm-display-resolver.test.cjs`, `components/search/addresssearchresults.js`, `components/myportal/viewall.js`, `components/case/summaryTypes/pinswg_nonvalidationid.js`, `components/case/summaryTypes/pinswg_ldpid.js`, `components/case/summaryTypes/pinswg_householderappealhasid.js`, `components/case/summaryTypes/pinswg_callinss77id.js`, `components/case/summaryTypes/pinswg_environmentalpermittingid.js`, `components/case/summaryTypes/pinswg_dnsid.js`, `components/case/summaryTypes/pinswg_sipscase.js`, `memory-bank/change-log.md` +type: change +rationale: A manual verification defect showed some consumers were compensating for the prior resolver contract by passing `fallbackValue` values that duplicated the CRM display value. After the helper was corrected to prefer the CRM display value whenever present, those redundant fallbacks needed to be re-characterized in tests and simplified without changing user-facing behaviour. +impact: Behaviour-preserving CRM display helper bug-fix slice. Tests now verify the corrected contract for English, Welsh, and missing-value cases. Redundant `fallbackValue: value || ...` and `fallbackValue: value || ""` patterns were simplified only where the fallback merely duplicated the CRM display value. No helper API, translation datasets, routes, CRM queries, lifecycle logic, business policy, rendering structure, or field names changed. +status: completed + +Summary: + +- Continued on existing branch: + - `feature/crm-display-resolver-slice1` +- Helper behavioural contract verified by characterization tests: + - if no CRM display value exists, return `fallbackValue` + - English always returns the CRM display value + - Welsh returns the Welsh translation when available + - Welsh otherwise returns the CRM display value +- Tests updated to cover: + - English with value returns value + - Welsh with translation returns Welsh + - Welsh without translation returns English value + - Missing value returns fallback + - Empty string returns fallback + - Null returns fallback + - Undefined returns fallback +- Redundant fallback simplifications applied only where safe: + - `components/search/addresssearchresults.js` + - `components/myportal/viewall.js` + - `components/case/summaryTypes/pinswg_nonvalidationid.js` + - `components/case/summaryTypes/pinswg_ldpid.js` + - `components/case/summaryTypes/pinswg_householderappealhasid.js` + - `components/case/summaryTypes/pinswg_callinss77id.js` + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` + - `components/case/summaryTypes/pinswg_dnsid.js` + - `components/case/summaryTypes/pinswg_sipscase.js` +- Left unchanged where fallback meaning differed from the CRM display value or was ambiguous. +- Behaviour preserved: + - no helper API change + - no translation data change + - no route or CRM query change + - no lifecycle or business-policy change + - no rendering-structure or field-name change + +Validation: + +- Required: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint tests/phase22/crm-display-resolver.test.cjs components/search/addresssearchresults.js components/myportal/viewall.js components/case/summaryTypes/pinswg_nonvalidationid.js components/case/summaryTypes/pinswg_ldpid.js components/case/summaryTypes/pinswg_householderappealhasid.js components/case/summaryTypes/pinswg_callinss77id.js components/case/summaryTypes/pinswg_environmentalpermittingid.js components/case/summaryTypes/pinswg_dnsid.js components/case/summaryTypes/pinswg_sipscase.js` +- Optional baseline check: + - `node tests/phase22/index.test.cjs` + - unrelated existing drift retained in `tests/phase22/case-service-behaviour.test.cjs` + +Follow-ups: + +- None in this slice. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SUMMARY-BATCH: adopt CRM display resolver in summary batch + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_maintenanceoflands217id.js`, `components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js`, `components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js`, `components/case/summaryTypes/pinswg_planningobligationappeals106id.js`, `memory-bank/change-log.md` +type: change +rationale: Continue the CRM display resolver adoption stream in one bounded summary batch by migrating only structurally equivalent direct CRM formatted/display value translation branches to the already-verified resolver helper, while leaving unrelated working-tree changes and non-compatible summary concerns untouched. +impact: Behaviour-preserving maintainability slice. Four structurally equivalent summary types now use `resolveCrmDisplayValue(...)` for compatible CRM display-value branches only. No helper contract, tests, translation datasets, routes, CRM queries, lifecycle logic, linked-case behaviour, or rendering structure changed. +status: completed + +Summary: + +- Branch confirmed before work: + - `feature/crm-display-resolver-slice1` +- Protected/unrelated files left untouched: + - `components/case/summaryTypes/pinswg_planningappeals78id.js` + - `.env.local` + - untracked analysis files +- Summary types adopted in this batch: + - `components/case/summaryTypes/pinswg_maintenanceoflands217id.js` + - `components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js` + - `components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js` + - `components/case/summaryTypes/pinswg_planningobligationappeals106id.js` +- Characterization findings across all four files: + - English behaviour: + - direct CRM formatted/display values were rendered for case type, EIA required, procedure, type of event, status, and decision + - Welsh behaviour: + - the same fields used direct JSONPath lookup against `lookuptranslations.json` and returned `value_cy` + - Compatible CRM formatted/display value branches: + - case type + - EIA required + - procedure + - type of event + - status + - decision + - Fallback behaviour preserved exactly: + - case type -> `t("case:summary-no-date-entered-label")` + - EIA required -> `t("case:summary-to-be-confirmed-label")` + - procedure -> `""` + - type of event -> `""` + - status -> `t("case:summary-no-date-entered-label")` + - decision -> `t("case:summary-no-information-to-date-label")` + - Empty/null handling preserved via existing helper contract and unchanged surrounding summary logic + - Consumer-specific behaviour left unchanged: + - LPA display via `getCaseLpaDisplayLines(...)` + - linked case logic + - key dates/lifecycle interpretation + - commented legacy blocks +- All four files were structurally equivalent and safe, so none needed to be skipped. + +Validation: + +- `node tests/phase22/crm-display-resolver.test.cjs` +- `npx eslint components/case/summaryTypes/pinswg_maintenanceoflands217id.js components/case/summaryTypes/pinswg_lawfuldevelopmentcertificatappid.js components/case/summaryTypes/pinswg_communityinfrastructurelevyid.js components/case/summaryTypes/pinswg_planningobligationappeals106id.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` + +Follow-ups: + +- Remaining adoption backlog should continue only in bounded summary-type slices, excluding already migrated files and any files with unrelated working-tree changes. + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-CLOSEOUT: close out CRM Display Infrastructure resolver adoption stream + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SUMMARY-BATCH-3: continue CRM display resolver summary adoption + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_commonlandid.js`, `components/case/summaryTypes/pinswg_miscellaneouscasewordid.js`, `components/case/summaryTypes/pinswg_wayleaveid.js`, `components/case/summaryTypes/pinswg_hedgeshedgerowstreepreservatioid.js`, `memory-bank/change-log.md` +type: change +rationale: Continue the summary-only CRM display resolver adoption stream in one bounded batch by replacing only structurally safe CRM formatted/display-value translation branches in the next likely-safe summaries, while preserving protected files and intentionally retained keyed/mixed translation concerns. +impact: Behaviour-preserving maintainability slice. Four additional summary types now delegate compatible single-value CRM display translation branches to `resolveCrmDisplayValue(...)`. No helper contract change, no relevant-authority keyed lookup change, no specialist-process policy change, and no route/lifecycle/linked-case/business-policy change. +status: completed + +Summary: + +- Continued on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit before this slice: + - `519a9fda` (`Continue CRM display resolver summary adoption`) +- Protected/unrelated working-tree items left untouched: + - `.env.local` + - untracked summary analysis files + - `components/case/summaryTypes/pinswg_planningappeals78id.js` +- Summary types adopted in this slice: + - `components/case/summaryTypes/pinswg_commonlandid.js` + - `components/case/summaryTypes/pinswg_miscellaneouscasewordid.js` + - `components/case/summaryTypes/pinswg_wayleaveid.js` + - `components/case/summaryTypes/pinswg_hedgeshedgerowstreepreservatioid.js` +- Summary types skipped: + - none of the requested four were skipped +- Characterization findings: + - Shared compatible CRM formatted/display-value branches confirmed in all four files: + - case type + - EIA required + - procedure + - type of event + - status + - decision + - English behaviour: + - these branches rendered direct CRM formatted/display values + - Welsh behaviour: + - these branches used direct JSONPath lookup into `lookuptranslations.json` and returned `value_cy` + - Fallback behaviour preserved exactly: + - case type -> `t("case:summary-no-date-entered-label")` + - EIA required -> `t("case:summary-to-be-confirmed-label")` + - procedure -> `""` + - type of event -> `""` + - status -> `t("case:summary-no-date-entered-label")` + - decision -> `t("case:summary-no-information-to-date-label")` + - Empty/null handling preserved through the verified helper contract plus unchanged surrounding summary logic + - Consumer-specific behaviour left unchanged: + - `pinswg_commonlandid.js` / `pinswg_miscellaneouscasewordid.js` / `pinswg_wayleaveid.js` + - relevant-authority lookup via `pinswg_lpa` keyed translation branch + - `pinswg_hedgeshedgerowstreepreservatioid.js` + - specialist case process translation branch + - relevant-authority lookup via `pinswg_lpa` keyed translation branch + - LPA rendering via `getCaseLpaDisplayLines(...)` + - linked-case rendering and status + - date sections and field-specific source variations +- Safe-adoption exclusions observed: + - no keyed lookup translation branches changed + - no `pinswg_lpa` lookup logic changed + - no specialist-case-process mixed branch changed + - no linked-case, lifecycle, or business-policy logic changed + +Validation: + +- `node tests/phase22/crm-display-resolver.test.cjs` +- `npx eslint components/case/summaryTypes/pinswg_commonlandid.js components/case/summaryTypes/pinswg_miscellaneouscasewordid.js components/case/summaryTypes/pinswg_wayleaveid.js components/case/summaryTypes/pinswg_hedgeshedgerowstreepreservatioid.js` + +Follow-ups: + +- Remaining summary backlog should continue only in bounded batches where the standard CRM display-value translation pattern can be isolated without touching keyed/mixed branches. + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SUMMARY-BATCH-2: continue CRM display resolver summary adoption + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_enforcementnoticeappeals174id.js`, `components/case/summaryTypes/pinswg_enforcementlistedbuildingconseid.js`, `components/case/summaryTypes/pinswg_listedbuildingandconservationrid.js`, `components/case/summaryTypes/pinswg_planningconditionss73s79id.js`, `memory-bank/change-log.md` +type: change +rationale: Continue the summary-only CRM display resolver adoption stream in one bounded batch by replacing only the remaining structurally identical CRM formatted/display-value translation branches, while preserving protected files, helper boundaries, and any non-matching translation patterns. +impact: Behaviour-preserving maintainability slice. Four additional summary types now delegate the standard CRM display-value translation path to `resolveCrmDisplayValue(...)` for compatible rows only. No helper API or helper behaviour change, no translation-data change, no keyed/list/hyperlink/LPA-specific translation change, and no route, lifecycle, post-decision, linked-case, or business-policy change. +status: completed + +Summary: + +- Continued on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit before this slice: + - `b56c8d46` (`Adopt CRM display resolver in summary batch`) +- Protected/unrelated working-tree items left untouched: + - `.env.local` + - untracked analysis files + - `components/case/summaryTypes/pinswg_planningappeals78id.js` +- Summary types adopted in this slice: + - `components/case/summaryTypes/pinswg_enforcementnoticeappeals174id.js` + - `components/case/summaryTypes/pinswg_enforcementlistedbuildingconseid.js` + - `components/case/summaryTypes/pinswg_listedbuildingandconservationrid.js` + - `components/case/summaryTypes/pinswg_planningconditionss73s79id.js` +- Characterization findings across the selected files: + - Compatible CRM formatted/display-value branches matched exactly: + - case type + - EIA required + - procedure + - type of event + - status + - decision + - English behaviour before adoption: + - each compatible row rendered the direct CRM formatted/display value + - Welsh behaviour before adoption: + - each compatible row used direct `jsonpath` lookup into `lookuptranslations.json` and returned `value_cy` + - Fallback behaviour preserved exactly: + - case type -> `t("case:summary-no-date-entered-label")` + - EIA required -> `t("case:summary-to-be-confirmed-label")` + - procedure -> `""` + - type of event -> `""` + - status -> `t("case:summary-no-date-entered-label")` + - decision -> `t("case:summary-no-information-to-date-label")` + - Empty/null handling preserved via the verified helper contract and unchanged surrounding row logic + - Consumer-specific behaviour left unchanged: + - LPA rendering via `getCaseLpaDisplayLines(...)` + - linked-case rendering and case-link status + - date sections and field-specific date-source differences + - lifecycle/status interpretation beyond direct CRM display rows + - any non-selected translation concerns in other files +- Safe-adoption exclusions observed: + - no keyed lookup translations changed + - no `pinswg_lpa` lookup logic changed + - no project-type list translation changed + - no hyperlink/website rendering changed + - no map/project-description/linked-case/post-decision/business-policy logic changed + +Validation: + +- `node tests/phase22/crm-display-resolver.test.cjs` +- `npx eslint components/case/summaryTypes/pinswg_enforcementnoticeappeals174id.js components/case/summaryTypes/pinswg_enforcementlistedbuildingconseid.js components/case/summaryTypes/pinswg_listedbuildingandconservationrid.js components/case/summaryTypes/pinswg_planningconditionss73s79id.js` + +Follow-ups: + +- Remaining summary backlog should continue in bounded batches only for files still using direct JSONPath CRM display translation for the standard single-value pattern. + +date: 2026-06-30 +author: Cline +scope: `memory-bank/change-log.md` +type: milestone +rationale: Close out the completed CRM Display Infrastructure resolver adoption stream on `feature/crm-display-resolver-slice1` with one documentation-only checkpoint before any follow-on stream begins. +impact: Documentation/governance only; records completed adoption scope, helper boundary, preserved-behaviour guarantees, explicit non-goals, known unrelated baseline drift, and next-stream recommendation. No runtime, API, route, auth/session, CRM, relay, storage, Notify, PDF, or workflow behaviour change. +status: completed + +Summary: + +- Workstream: + - CRM Display Infrastructure — resolver adoption stream +- Branch: + - `feature/crm-display-resolver-slice1` +- Shared helper introduced and retained unchanged across the stream: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Focused helper characterization coverage retained: + - `tests/phase22/crm-display-resolver.test.cjs` +- Helper responsibility recorded as: + - standard CRM formatted/display value -> Welsh lookup (`lookuptranslations.json -> value_cy`) -> existing consumer fallback +- Adopted consumers completed in this stream: + - `components/admin/tabs/appeals.js` + - `components/search/searchresults.js` + - `components/search/addresssearchresults.js` + - `components/search/dnssearchresults.js` + - `components/myportal/viewall.js` + - `components/case/summaryTypes/pinswg_nonvalidationid.js` + - `components/case/summaryTypes/pinswg_ldpid.js` + - `components/case/summaryTypes/pinswg_householderappealhasid.js` + - `components/case/summaryTypes/pinswg_callinss77id.js` + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` + - `components/case/summaryTypes/pinswg_dnsid.js` + - `components/case/summaryTypes/pinswg_sipscase.js` +- Preserved behaviour guarantees across the stream: + - helper API remained unchanged + - consumer-specific fallback behaviour was preserved + - empty-string/null behaviour was preserved per consumer + - incompatible or mixed concerns were intentionally left unchanged + - no API, route, auth/session, CRM query, relay, storage, Notify, PDF, or workflow behaviour was changed +- Explicit helper boundary / non-goals recorded: + - helper owns only standard CRM formatted/display value -> Welsh lookup -> fallback + - helper does **not** own: + - keyed lookup translation + - list item translation + - hyperlink-mixed rendering + - relevant-authority lookup + - project-type translation + - lifecycle/status interpretation + - post-decision interpretation +- Known unrelated baseline drift retained and not fixed in this stream: + - `tests/phase22/case-service-behaviour.test.cjs` + - legacy expected route: `/api/endpoint/getportalmoduledetails_api` + - current route: `/api/myportal/get-portal-module-details` +- Working tree caution retained: + - `.env.local` remains modified and uncommitted outside this stream + +Validation: + +- Focused documentation validation intended for closeout: + - `git diff --check -- memory-bank/change-log.md` + +Follow-ups: + +- Recommended next stream: + - begin a new clearly scoped maintainability stream outside this closeout, likely one of: + - non-summary CRM display adoption only if a remaining consumer still matches the same helper boundary + - a separate explicitly approved abstraction stream for non-matching translation shapes (keyed lookups, list translation, hyperlink-mixed rendering) + - do **not** broaden `resolveCrmDisplayValue()` by default. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE12: adopt shared CRM display resolver in SIPS summary + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_sipscase.js`, `memory-bank/change-log.md` +type: change +rationale: Execute a dedicated high-risk, characterization-first SIPS summary slice by adopting the shared CRM display resolver only for the safe subset of direct CRM formatted/display-value translation branches. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_sipscase.js` now delegates a bounded set of repeated bilingual CRM display-value resolution branches to the shared resolver for case type, procedure, ES Submitted, Deemed Marine License Applied for, and decision while preserving project-type list translation, website handling, project description rendering, linked-case behaviour, lifecycle/date/reporting sections, and post-decision/redetermination sections. No route, lifecycle, business policy, or linked-case behaviour change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `a7ce84c1` +- Selected summary type: + - `components/case/summaryTypes/pinswg_sipscase.js` +- Characterization findings: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - project type renders a list from `detailsObj.pinswg_sips_pinswg_sipsprojecttype` + - website renders a link using `detailsObj.pinswg_webaddress` + - procedure renders `detailsObj["pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue"]` + - ES Submitted renders `detailsObj["pinswg_essubmitted@OData.Community.Display.V1.FormattedValue"]` + - Deemed Marine License Applied for renders `detailsObj["pinswg_deemedmarinelicenseappliedfor@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - redetermination renders `detailsObj["pinswg_redetermination@OData.Community.Display.V1.FormattedValue"]` directly in the post-decision section + - Welsh behaviour: + - safe adopted CRM branches used JSONPath against `lookuptranslations.json` and returned `value_cy` + - project-type list translation uses per-item Welsh lookup and remains distinct from the shared helper abstraction + - website row also uses Welsh lookup but is mixed with hyperlink rendering and URL formatting + - JSONPath lookup pattern: + - safe subset matched: + - `CRM formatted/display value -> lookuptranslations.json -> value_cy` + - project-type list translation is list-based rather than a single summary-row CRM branch + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - procedure -> original display value or `t("case:summary-to-be-confirmed-label")` when source branch is null + - ES Submitted -> original display value or `t("case:summary-to-be-confirmed-label")` when source branch is null + - Deemed Marine License Applied for -> original display value or `t("case:summary-to-be-confirmed-label")` when source branch is null + - decision -> original display value or `t("case:summary-no-information-to-date-label")` when source branch is null + - project type / website / post-decision sections retain existing bespoke behaviour + - empty/null handling preserved: + - helper fallback preserves existing field-specific fallback values for null / undefined / empty-string inputs in adopted branches + - procedure, ES Submitted, Deemed Marine License Applied for, and decision retain their original outer null-guard branches + - all SIPS lifecycle/date/reporting sections remain unchanged and continue to rely on existing `hasOwn(...)`, `hasValidKey(...)`, and `_.isEmpty(...)` checks + - CRM source fields: + - adopted branches: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue` + - `pinswg_essubmitted@OData.Community.Display.V1.FormattedValue` + - `pinswg_deemedmarinelicenseappliedfor@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - unadopted branches / mixed concerns: + - `projectType.pinswg_name` list translation + - `pinswg_webaddress` + - `pinswg_redetermination@OData.Community.Display.V1.FormattedValue` + - project-type list translation behaviour: + - per-project-type item translation through `projectType.pinswg_name` + - intentionally left unchanged because it is a list-based concern, not a simple single-value CRM display branch + - website behaviour: + - English renders hyperlink markup + - Welsh uses lookup + link-related logic in same branch + - intentionally left unchanged + - SIPS-specific lifecycle/date/reporting sections: + - extensive pre-submission, submission, reporting/decision, and post-decision sections remain unchanged + - case deadline uses latest extension selection logic and remains unchanged + - post-decision/redetermination sections: + - redetermination and redetermination consultation deadline remain unchanged + - although redetermination uses a formatted value, it sits inside a post-decision interpretation area and was left unchanged for scope safety + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` rendering remains unchanged + - map/project-specific rendering: + - project description rendering remains unchanged + - project type list rendering remains unchanged + - imported map-related concerns remain untouched in this slice + - option-set / yes-no translations: + - ES Submitted is a direct option-set style formatted-value branch and was safely adoptable + - Deemed Marine License Applied for is likewise safely adoptable as a direct formatted-value branch + - branches compatible with `resolveCrmDisplayValue(...)`: + - case type + - procedure + - ES Submitted + - Deemed Marine License Applied for + - decision + - branches intentionally left unchanged: + - project-type list translation + - website / hyperlink rendering + - project description rendering + - linked-case rendering + - all SIPS lifecycle/date/reporting sections + - post-decision/redetermination section + - commented-out status/type-of-event/recommendation branches +- Safe branches adopted: + - case type + - procedure + - ES Submitted + - Deemed Marine License Applied for + - decision +- Branches left unchanged: + - project-type list translation + - left unchanged because it is a per-item list translation concern rather than a simple single CRM display-value branch + - website row + - left unchanged because it mixes Welsh lookup with hyperlink rendering and URL formatting + - project description rendering + - linked-case rendering + - all SIPS lifecycle/date/reporting sections + - post-decision/redetermination section + - left unchanged because it sits inside a post-decision interpretation area and changing it would broaden scope beyond straightforward display-value resolution +- Consumer-specific nuances preserved: + - procedure retains `to-be-confirmed` fallback when source branch is null + - ES Submitted retains `to-be-confirmed` fallback when source branch is null + - Deemed Marine License Applied for retains `to-be-confirmed` fallback when source branch is null + - decision retains `no-information-to-date` fallback when source branch is null + - project-type list translation remains per-item and unchanged + - website link behaviour remains unchanged + - post-decision/redetermination behaviour remains unchanged +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged + - `resolveCrmDisplayValue()` remains the correct abstraction for the standard CRM formatted/display-value translation concern only + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_sipscase.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- CRM Display Infrastructure adoption backlog status: + - the previously targeted high-risk summary surfaces in this sequence have now been adopted where safe + - remaining future work, if any, should focus on non-summary consumers or on separate, explicitly approved abstraction work for translation shapes that do **not** match the current helper (for example keyed lookup/list translation concerns) + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE11A: adopt shared CRM display resolver in DNS summary + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_dnsid.js`, `memory-bank/change-log.md` +type: change +rationale: Start the DNS/SIPS summary adoption batch with the preferred DNS candidate, adopting the shared CRM display resolver only for the safe subset of repeated CRM display-value translation branches. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_dnsid.js` now delegates the standard repeated bilingual CRM display-value resolution branches to the shared resolver for case type, EIA required, procedure, type of event, and decision while preserving DNS-specific project/map behaviour, website rendering, fallback behaviour, linked-case rendering, and date/lifecycle sections. No route, lifecycle, business policy, or linked-case behaviour change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `365fce2e` +- Summary types reviewed in this batch stage: + - `components/case/summaryTypes/pinswg_dnsid.js` +- Summary types adopted in this stage: + - `components/case/summaryTypes/pinswg_dnsid.js` +- Characterization findings for DNS summary: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - website renders a link using `detailsObj.pinswg_webaddress` + - EIA required renders `detailsObj["pinswg_eiarequired@OData.Community.Display.V1.FormattedValue"]` + - procedure renders `detailsObj["pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue"]` + - type of event renders `detailsObj["pinswg_typeofevent@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - Welsh behaviour: + - the adopted CRM display branches used JSONPath against `lookuptranslations.json` and returned `value_cy` + - website row also used JSONPath in Welsh, but it is not a standard CRM formatted/display-value branch and remains unchanged + - duplicated JSONPath lookup pattern: + - safe subset matched the established pattern: + - `$..[?(@ && @.value=="")].value_cy` + - one branch (`EIA required`) used the shorter historical `jsonpath(path, transLookup)` form but still matched the same translation concern + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - EIA required -> original display value or `t("case:summary-to-be-confirmed-label")` + - procedure -> original display value or `t("case:summary-to-be-confirmed-label")` when source branch is null + - type of event -> original display value or empty string + - decision -> original display value or `t("case:summary-no-information-to-date-label")` when source branch is null + - website -> unchanged existing behaviour + - empty/null handling preserved: + - helper fallback preserves existing field-specific fallback values for null / undefined / empty-string inputs in adopted branches + - procedure/decision retain their original outer null-guard branches + - DNS-specific date sections remain unchanged and continue to use existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields: + - adopted branches: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_eiarequired@OData.Community.Display.V1.FormattedValue` + - `pinswg_choiceofprocedure@OData.Community.Display.V1.FormattedValue` + - `pinswg_typeofevent@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - unadopted mixed concerns: + - `pinswg_webaddress` + - project description/map inputs + - DNS-specific derived values: + - project description section uses `getBilingualText(...)` + - map section derives coordinates through `OSPoint` and `MapComponent` + - these were intentionally left unchanged + - lifecycle/status interpretation: + - active status row is commented out in this summary and was not changed + - no lifecycle derivation was altered + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` rendering remains unchanged + - map/project-specific sections: + - project description section unchanged + - website row unchanged + - map rendering unchanged + - option-set / yes-no translations: + - `EIA required` remains safely adoptable + - branches compatible with `resolveCrmDisplayValue(...)`: + - case type + - EIA required + - procedure + - type of event + - decision + - branches intentionally left unchanged: + - website row + - project description section + - map rendering + - linked-case rendering + - all DNS-specific date/lifecycle sections + - commented-out status/event branches +- Safe branches adopted: + - case type + - EIA required + - procedure + - type of event + - decision +- Branches left unchanged: + - website row + - left unchanged because it mixes Welsh lookup behaviour with hyperlink rendering and URL formatting + - project description / map sections + - left unchanged because they are DNS-specific derived display concerns + - linked-case rendering + - all DNS date/lifecycle/reporting sections + - commented-out status/event/recommendation branches +- Consumer-specific nuances preserved: + - procedure keeps `to-be-confirmed` fallback when source branch is null + - type of event keeps empty-string fallback + - decision keeps `no-information-to-date` fallback when source branch is null + - website link behaviour remains unchanged + - project/map rendering remains unchanged +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged from the DNS summary + - `resolveCrmDisplayValue()` remains the correct abstraction for the standard CRM formatted/display-value translation concern only + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_dnsid.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this stage + +Follow-ups: + +- Batch status after DNS stage: + - DNS safely adopted and validated + - SIPS characterization may proceed separately in the same batch only if its safe subset remains equally bounded + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE10: adopt shared CRM display resolver in environmental permitting summary + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_environmentalpermittingid.js`, `memory-bank/change-log.md` +type: change +rationale: Execute the first high-risk, characterization-first summary adoption slice by adopting the shared CRM display resolver only for the safe subset of repeated CRM display-value translation branches in the environmental permitting summary. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_environmentalpermittingid.js` now delegates the standard repeated bilingual CRM display-value resolution branches to the shared resolver for case type, EIA required, procedure, type of event, status, and decision while preserving fallback behaviour, linked-case rendering, date handling, summary structure, and the distinct relevant-authority lookup branch. No route, lifecycle, business policy, or linked-case behaviour change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `f0deda58` +- Selected summary type: + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` +- Characterization findings: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - EIA required renders `detailsObj["pinswg_eiarequired@OData.Community.Display.V1.FormattedValue"]` + - procedure renders `detailsObj["pinswg_procedure@OData.Community.Display.V1.FormattedValue"]` + - type of event renders `detailsObj["pinswg_typeofevent@OData.Community.Display.V1.FormattedValue"]` + - status renders `casesObj["statuscode@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - relevant authority renders an authority-name lookup through `pinswg_lpa -> value` + - Welsh behaviour: + - the six standard CRM display fields used JSONPath against `lookuptranslations.json` and returned `value_cy` + - relevant authority used a different lookup shape through `pinswg_lpa -> value_cy` + - duplicated JSONPath lookup pattern: + - safe subset matched the standard pattern: + - `$..[?(@ && @.value=="")].value_cy` + - one branch (`EIA required`) used the shorter historical `jsonpath(path, transLookup)` form but still matched the same translation concern + - one branch (`relevant authority`) did **not** match the helper abstraction because it resolves by `pinswg_lpa` key rather than by CRM formatted/display `value` + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - EIA required -> original display value or `t("case:summary-to-be-confirmed-label")` + - procedure -> original display value or empty string + - type of event -> original display value or empty string + - status -> original display value or `t("case:summary-no-date-entered-label")` + - decision -> original display value or `t("case:summary-no-information-to-date-label")` + - relevant authority -> existing `pinswg_lpa` JSONPath lookup result or `t("case:summary-no-date-entered-label")` + - empty/null handling preserved: + - helper fallback preserves existing field-specific fallback values for null / undefined / empty-string inputs in the adopted branches + - relevant authority remains on its existing bespoke lookup path + - key date rows remain unchanged and still rely on existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields: + - adopted branches: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_eiarequired@OData.Community.Display.V1.FormattedValue` + - `pinswg_procedure@OData.Community.Display.V1.FormattedValue` + - `pinswg_typeofevent@OData.Community.Display.V1.FormattedValue` + - `statuscode@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - unadopted branch: + - `detailsObj.pinswg_relevantauthorityname` matched against translation entries using `pinswg_lpa` + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` rendering remains unchanged + - lifecycle/status interpretation: + - direct formatted-value display only; no derived lifecycle logic changed + - project/map/environmental-permitting-specific sections: + - no map/project rendering logic was changed in this slice + - the environmental-permitting-specific `relevant authority` lookup branch was intentionally preserved unchanged + - derived display values: + - none for the adopted CRM display branches + - option-set/yes-no translations: + - `EIA required` remains an option-set/yes-no style translation branch and was safely adoptable + - branches compatible with `resolveCrmDisplayValue(...)`: + - case type + - EIA required + - procedure + - type of event + - status + - decision + - branches not compatible without changing behaviour: + - relevant authority + - reason: it uses a different translation lookup shape (`pinswg_lpa -> value/value_cy`) rather than the established CRM formatted/display value -> `value_cy` helper abstraction +- Safe branches adopted: + - case type + - EIA required + - procedure + - type of event + - status + - decision +- Branches left unchanged: + - relevant authority + - left unchanged because it is not a standard CRM formatted/display-value translation branch and would require broader helper responsibilities or a separate abstraction to preserve behaviour safely + - linked-case rendering + - LPA display rendering + - key-dates rendering +- Consumer-specific nuances preserved: + - `EIA required` retains `to-be-confirmed` fallback + - `procedure` retains empty-string fallback + - `type of event` retains empty-string fallback + - `relevant authority` retains bespoke `pinswg_lpa` lookup behaviour in EN/CY + - section ordering and summary structure remain unchanged +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged + - `resolveCrmDisplayValue()` remains the correct abstraction for the standard CRM formatted/display value translation concern only + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_environmentalpermittingid.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- Recommended next high-risk slice: + - `components/case/summaryTypes/pinswg_dnsid.js` + - reason: it is the next remaining high-risk candidate and should be approached before `pinswg_sipscase.js` because DNS-specific behaviour is likely narrower than the broader SIPS case summary concerns. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE9: adopt shared CRM display resolver in call-in summary + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_callinss77id.js`, `memory-bank/change-log.md` +type: change +rationale: Continue incremental CRM display resolver adoption with one bounded call-in summary slice, replacing only duplicated CRM bilingual display-resolution logic compatible with the established helper abstraction. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_callinss77id.js` now delegates repeated bilingual CRM display-value resolution to the shared resolver for case type, EIA required, procedure, type of event, status, and decision while preserving existing fallback behaviour, linked-case rendering, date handling, and summary structure. No route, lifecycle, business policy, or linked-case behaviour change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `f08a6ce1` +- Selected summary type: + - `components/case/summaryTypes/pinswg_callinss77id.js` +- Characterization findings: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - EIA required renders `detailsObj["pinswg_eiarequired@OData.Community.Display.V1.FormattedValue"]` + - procedure renders `detailsObj["pinswg_procedure@OData.Community.Display.V1.FormattedValue"]` + - type of event renders `detailsObj["pinswg_typeofevent@OData.Community.Display.V1.FormattedValue"]` + - status renders `casesObj["statuscode@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - Welsh behaviour: + - each of the above fields used JSONPath against `lookuptranslations.json` and returned `value_cy` + - duplicated JSONPath lookup pattern: + - `$..[?(@ && @.value=="")].value_cy` + - one branch (`EIA required`) used the shorter historical `jsonpath(path, transLookup)` form but still followed the same value -> `value_cy` translation pattern + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - EIA required -> original display value or `t("case:summary-to-be-confirmed-label")` + - procedure -> original display value or empty string + - type of event -> original display value or empty string + - status -> original display value or `t("case:summary-no-date-entered-label")` + - decision -> original display value or `t("case:summary-no-information-to-date-label")` + - empty/null handling preserved: + - helper fallback now preserves existing field-specific fallback values for null / undefined / empty-string inputs + - key date rows remain unchanged and still rely on existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_eiarequired@OData.Community.Display.V1.FormattedValue` + - `pinswg_procedure@OData.Community.Display.V1.FormattedValue` + - `pinswg_typeofevent@OData.Community.Display.V1.FormattedValue` + - `statuscode@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - lifecycle/status interpretation: + - direct formatted-value display only; no derived lifecycle logic changed + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` rendering remains unchanged + - additional CRM lookup branches: + - EIA-required option-set translation branch was present and compatible with the helper abstraction, so it was adopted + - any derived display values: + - none for the adopted CRM display branches +- Adopted CRM lookup branches: + - case type + - EIA required + - procedure + - type of event + - status + - decision +- Intentionally unadopted branches: + - none of the duplicated CRM bilingual display-resolution branches in this summary needed to remain unchanged + - non-CRM summary concerns were intentionally left unchanged: + - LPA rendering via `getCaseLpaDisplayLines(...)` + - linked-case rows + - all key-date rows +- Consumer-specific nuances preserved: + - `EIA required` retains `to-be-confirmed` fallback + - `procedure` retains empty-string fallback + - `type of event` retains empty-string fallback + - linked-case rows and counts remain untouched + - date handling and translated labels remain untouched +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged + - `resolveCrmDisplayValue()` remains the correct abstraction for this repeated presentation concern + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_callinss77id.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- Recommended first high-risk adoption candidate: + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` + - reason: it is structurally closer to the now-proven summary pattern than the DNS/SIPS-heavy summaries and introduces one extra relevant-authority CRM lookup branch without the added map/project complexity present in higher-risk DNS/SIPS variants. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE8: adopt shared CRM display resolver in householder summary + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_householderappealhasid.js`, `memory-bank/change-log.md` +type: change +rationale: Continue incremental CRM display resolver adoption with one bounded householder summary slice, replacing only duplicated CRM bilingual display-resolution logic that matches the established helper abstraction. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_householderappealhasid.js` now delegates repeated bilingual CRM display-value resolution to the shared resolver for case type, EIA required, procedure, status, and decision while preserving existing fallback behaviour, linked-case rendering, key date handling, and summary structure. No route, lifecycle, business policy, or linked-case behaviour change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `40c87fa4` +- Selected summary type: + - `components/case/summaryTypes/pinswg_householderappealhasid.js` +- Characterization findings: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - EIA required renders `detailsObj["pinswg_eiarequired@OData.Community.Display.V1.FormattedValue"]` + - procedure renders `detailsObj["pinswg_procedure@OData.Community.Display.V1.FormattedValue"]` + - status renders `casesObj["statuscode@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - Welsh behaviour: + - each of the above fields used JSONPath against `lookuptranslations.json` and returned `value_cy` + - duplicated JSONPath lookup pattern: + - `$..[?(@ && @.value=="")].value_cy` + - one branch (`EIA required`) used the shorter historical `jsonpath(path, transLookup)` form but still followed the same value -> `value_cy` translation pattern + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - EIA required -> original display value or `t("case:summary-to-be-confirmed-label")` + - procedure -> original display value or empty string + - status -> original display value or `t("case:summary-no-date-entered-label")` + - decision -> original display value or `t("case:summary-no-information-to-date-label")` + - empty/null handling preserved: + - helper fallback now preserves existing field-specific fallback values for null / undefined / empty-string inputs + - key date rows remain unchanged and still rely on existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_eiarequired@OData.Community.Display.V1.FormattedValue` + - `pinswg_procedure@OData.Community.Display.V1.FormattedValue` + - `statuscode@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - summary-specific derived values: + - none for the adopted CRM display branches + - lifecycle/status interpretation: + - direct formatted-value display only; no extra derived lifecycle logic changed + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` rendering remains unchanged + - additional CRM lookup branches: + - EIA-required option-set translation branch was present and was compatible with the existing helper abstraction, so it was adopted +- CRM lookup branches adopted: + - case type + - EIA required + - procedure + - status + - decision +- Branches intentionally left unchanged: + - none of the duplicated CRM bilingual display-resolution branches in this summary needed to remain unchanged + - non-CRM summary concerns were intentionally left unchanged: + - LPA rendering via `getCaseLpaDisplayLines(...)` + - linked-case rows + - all key-date rows +- Consumer-specific nuances preserved: + - `EIA required` retains `to-be-confirmed` fallback rather than `no-date-entered` + - `procedure` retains empty-string fallback + - linked-case rows and counts remain untouched + - date handling and translated labels remain untouched +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged + - `resolveCrmDisplayValue()` remains the correct abstraction for this repeated presentation concern + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_householderappealhasid.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- Recommended Slice 9: + - `components/case/summaryTypes/pinswg_callinss77id.js` + - reason: it is the remaining reviewed medium-risk candidate and should be assessed next using the same bounded characterization-first approach. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE7: adopt shared CRM display resolver in LDP summary type + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_ldpid.js`, `memory-bank/change-log.md` +type: change +rationale: Continue proven incremental CRM display resolver adoption with one carefully selected medium-risk summary type while preserving all summary-specific behaviour. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_ldpid.js` now delegates repeated bilingual CRM display-value resolution to the shared resolver for case type, procedure, type of event, status, and decision while preserving existing linked-case behaviour, date rendering, fallback labels, and summary structure. No route, lifecycle interpretation, business policy, or rendering-sequence change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `d05c1911` +- Summary types reviewed (medium-risk candidates only): + - `components/case/summaryTypes/pinswg_householderappealhasid.js` + - `components/case/summaryTypes/pinswg_callinss77id.js` + - `components/case/summaryTypes/pinswg_ldpid.js` +- Selected summary type for Slice 7: + - `components/case/summaryTypes/pinswg_ldpid.js` +- Selection rationale: + - all three candidates shared the dominant repeated CRM bilingual lookup pattern + - `pinswg_ldpid.js` was the safest medium-risk candidate because it has fewer duplicated CRM lookup branches than the other two reviewed files + - unlike `pinswg_householderappealhasid.js` and `pinswg_callinss77id.js`, it does not add an extra EIA-required CRM translation branch + - it remains read-only, retains straightforward linked-case behaviour, and avoids additional summary-specific CRM display branches beyond the selected repeated pattern +- Characterization findings for the selected summary type: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - procedure renders `detailsObj["pinswg_procedure@OData.Community.Display.V1.FormattedValue"]` + - type of event renders `detailsObj["pinswg_typeofevent@OData.Community.Display.V1.FormattedValue"]` + - status renders `casesObj["statuscode@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decision@OData.Community.Display.V1.FormattedValue"]` + - Welsh behaviour: + - each of the above fields used JSONPath against `lookuptranslations.json` and returned `value_cy` + - duplicated JSONPath lookup pattern: + - `$..[?(@ && @.value=="")].value_cy` + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - procedure -> original display value or empty string + - type of event -> original display value or empty string + - status -> original display value or `t("case:summary-no-date-entered-label")` + - decision -> original display value or `t("case:summary-no-information-to-date-label")` + - empty/null handling preserved: + - helper fallback now preserves the existing field-specific fallback values for null/undefined/empty inputs + - all date rows remain unchanged and still rely on existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields preserved: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `pinswg_procedure@OData.Community.Display.V1.FormattedValue` + - `pinswg_typeofevent@OData.Community.Display.V1.FormattedValue` + - `statuscode@OData.Community.Display.V1.FormattedValue` + - `pinswg_decision@OData.Community.Display.V1.FormattedValue` + - summary-specific derived values: + - none for the adopted CRM display fields + - lifecycle/status interpretation: + - direct formatted-value display only; no extra derived lifecycle logic added or changed + - linked-case behaviour: + - existing `numberofchildincidents` / `linkedCasesList(...)` behaviour remains unchanged +- Consumer-specific nuances preserved: + - LPA rendering remains via `getCaseLpaDisplayLines(...)` + - linked-case rows remain unchanged + - all key-dates rendering remains unchanged + - no attempt made to standardize empty-string vs label fallback behaviour across fields +- Helper assessment: + - no helper API changes were required + - no new reusable abstraction emerged + - `resolveCrmDisplayValue()` remains the correct abstraction for this repeated presentation concern + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_ldpid.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- Remaining work is now mostly incremental adoption. +- Recommended next adoption slice: + - `components/case/summaryTypes/pinswg_householderappealhasid.js` + - reason: it is the next closest match to the proven summary pattern and should provide another medium-risk proof before considering `pinswg_callinss77id.js`. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE6: adopt shared CRM display resolver in non-validation summary type + +date: 2026-06-30 +author: Cline +scope: `components/case/summaryTypes/pinswg_nonvalidationid.js`, `memory-bank/change-log.md` +type: change +rationale: Prove the CRM display resolver can be adopted safely in one low-risk summary type without broadening summary refactor scope. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/case/summaryTypes/pinswg_nonvalidationid.js` now delegates repeated bilingual CRM display-value resolution to the shared resolver for case type, status, and decision while preserving the existing summary rendering structure, fallback labels, and date handling. No route, payload, lifecycle interpretation, linked-case behaviour, or workflow logic change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `0774783cd54c652947694de7812b5a2cc0f3a5c9` +- Selected summary type for Slice 6: + - `components/case/summaryTypes/pinswg_nonvalidationid.js` +- Summary types reviewed for selection: + - Low Risk: + - `components/case/summaryTypes/pinswg_nonvalidationid.js` + - Medium Risk: + - `components/case/summaryTypes/pinswg_householderappealhasid.js` + - `components/case/summaryTypes/pinswg_callinss77id.js` + - `components/case/summaryTypes/pinswg_ldpid.js` + - High Risk: + - `components/case/summaryTypes/pinswg_dnsid.js` + - `components/case/summaryTypes/pinswg_sipscase.js` + - `components/case/summaryTypes/pinswg_environmentalpermittingid.js` +- Selection rationale: + - `pinswg_nonvalidationid.js` is the safest proof candidate because it is small, read-only, and uses the dominant CRM formatted-value -> Welsh lookup pattern in only a few places. + - It has minimal conditional business logic, no lifecycle/status derivation beyond direct formatted-value display, no linked-case rendering branch, and no map/project/derived summary sections. +- Characterization findings for the selected summary type: + - English behaviour: + - case type renders `casesObj["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"]` + - status renders `casesObj["statuscode@OData.Community.Display.V1.FormattedValue"]` + - decision renders `detailsObj["pinswg_decisionissued@OData.Community.Display.V1.FormattedValue"]` + - Welsh behaviour: + - each of the above fields used JSONPath against `lookuptranslations.json` and rendered `value_cy` + - dominant JSONPath lookup pattern: + - `$..[?(@ && @.value=="")].value_cy` + - fallback behaviour preserved: + - case type -> original display value or `t("case:summary-no-date-entered-label")` + - status -> original display value or `t("case:summary-no-date-entered-label")` + - decision -> original display value or `t("case:summary-no-information-to-date-label")` + - empty/null handling preserved: + - helper falls back safely when value is null / undefined / empty string + - date rows remain unchanged and still use existing `hasOwn(...)` / `_.isEmpty(...)` checks + - CRM source fields preserved: + - `pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue` + - `statuscode@OData.Community.Display.V1.FormattedValue` + - `pinswg_decisionissued@OData.Community.Display.V1.FormattedValue` + - summary-specific derived values: + - none for the adopted CRM display fields +- Consumer-specific nuances preserved: + - LPA rendering remains delegated to `getCaseLpaDisplayLines(...)` and was intentionally not changed + - key dates card logic remains unchanged + - no attempt made to standardize or expand summary behaviour beyond the duplicated CRM display-resolution logic +- Helper assessment from this proof: + - no helper API changes were required + - no new reusable abstraction emerged from this slice + - `resolveCrmDisplayValue()` remains the correct abstraction for this repeated presentation concern + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/case/summaryTypes/pinswg_nonvalidationid.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Optional broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs` + - observed mismatch remains between expected legacy route `/api/endpoint/getportalmoduledetails_api` and current route `/api/myportal/get-portal-module-details` + - no change made to that unrelated baseline in this slice + +Follow-ups: + +- CRM Display Infrastructure is now sufficiently proven for continued adoption, but future work should remain incremental and summary-by-summary rather than broad migration. +- Prefer further low-risk adoptions before considering any wider summary sweep. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE5: adopt shared CRM display resolver in My Portal view all + +date: 2026-06-30 +author: Cline +scope: `components/myportal/viewall.js`, `memory-bank/change-log.md` +type: change +rationale: Continue CRM Display Infrastructure adoption in one mixed read-only My Portal list/worklist consumer while preserving per-worklist display differences. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/myportal/viewall.js` now delegates repeated Welsh CRM display-value lookup logic to the shared resolver for authority/LPA and case type in several worklist contexts, and for standard formatted-value status display where that pattern already existed. No dashboard policy, route, query parameter, auth/session, Redux shape, or rendering-structure change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `d0d971180134347d9e993161f01d9871d25337f6` +- Selected consumer for Slice 5: + - `components/myportal/viewall.js` +- My Portal worklist contexts affected: + - `awaitingSubmissionDetails` + - `watchedCases` + - `myCases` + - `myRepresentations` +- Characterization findings for this consumer: + - English behaviour: renders original CRM display/formatted values directly in the standard worklist cases + - Welsh behaviour: uses JSONPath against `lookuptranslations.json` and renders `value_cy` for repeated CRM display fields + - repeated dominant pattern present for: + - authority/LPA display + - case type display + - standard formatted-value status display + - fallback behaviour differs slightly by worklist and source field: + - many worklists use original display value or `N/A` + - `myRepresentations` preserves several blank-string fallbacks instead of global `N/A` + - empty/null handling remains safe through existing `hasOwn(...)` checks and branch-specific fallbacks + - this consumer is more mixed than the search-family slices because source fields vary by worklist and some values are derived from form collection metadata rather than direct CRM formatted values +- Comparison against prior slices: + - matches prior slices for repeated formatted-value -> locale -> translation lookup pattern + - unlike prior search-family slices, this consumer contains multiple worklist-specific branches with different source fields and different fallback semantics + - `awaitingSubmissionDetails` status uses `statuscode` lookup by status-code key rather than the common formatted-value lookup pattern, so that branch was intentionally left unchanged + - `myRepresentations` status is a derived created-date display (`repRaisedDate(...)`), not CRM bilingual display-resolution logic, and was intentionally left unchanged +- Reused existing shared helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Adopted helper only in the selected consumer and did not modify dashboard/worklist structure or navigation. + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/myportal/viewall.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs`, which still expects legacy route `/api/endpoint/getportalmoduledetails_api` while current repo behaviour uses grouped route `/api/myportal/get-portal-module-details` + - no change made to that unrelated test in this slice + +Follow-ups: + +- Recommended next slice: move to a low-risk summary proof rather than continue immediately into broader mixed consumers; if CRM display adoption continues, prefer one narrowly scoped summary-type or list-only proof where worklist/state branching is minimal. + +--- + +### CL-2026-06-30-CRM-DISPLAY-RESOLVER-SLICE4: adopt shared CRM display resolver in DNS search results + +date: 2026-06-30 +author: Cline +scope: `components/search/dnssearchresults.js`, `memory-bank/change-log.md` +type: change +rationale: Continue CRM Display Infrastructure adoption in one additional read-only search consumer while preserving DNS-specific derived display behavior. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/search/dnssearchresults.js` now delegates repeated Welsh CRM display-value lookup logic to the shared resolver for authority and status, and reuses it as the first step in DNS/SIP derived type display, without changing the existing DNS-specific derived label behaviour. No CRM query, route, payload, auth/session, or rendering-structure change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `236c707ec2955df9f9a9ad7c93ee751bfc75e89f` +- Selected consumer for Slice 4: + - `components/search/dnssearchresults.js` +- Characterization findings for this consumer: + - English behaviour: authority and status render original CRM formatted/display values directly + - Welsh behaviour: authority and status use JSONPath against `lookuptranslations.json` and render `value_cy` + - repeated dominant pattern present for: + - authority + - status + - the DNS/SIP type column has DNS-specific derived display behaviour: + - first resolves the underlying appeal case type label in EN/CY + - then collapses the resulting label to either `DNS` or `SIP` + - fallback behaviour: + - where source field exists, English uses original display value or `N/A` + - Welsh falls back to original display value / existing `N/A` path when translation missing + - where source field is absent, rendered value remains empty string + - empty/null handling remains safe through existing `hasOwn(...)` guards and unchanged fallbacks +- Comparison against prior slices: + - matches prior slices for dominant authority/status CRM bilingual lookup pattern + - unlike Slice 2, no status `.trim()` behaviour was present and none was introduced + - unlike Slice 3, there is only one authority source field in the active duplicated resolver usage here + - unlike all prior slices, this consumer contains a DNS-specific derived type reduction (`translated case type -> DNS/SIP`) +- Reused existing shared helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Adopted helper only in the selected consumer and did not modify surrounding rendering structure. + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/search/dnssearchresults.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs`, which still expects legacy route `/api/endpoint/getportalmoduledetails_api` while current repo behaviour uses grouped route `/api/myportal/get-portal-module-details` + - no change made to that unrelated test in this slice + +Follow-ups: + +- Recommended Slice 5: adopt the shared resolver in one further read-only consumer only, likely `components/myportal/viewall.js`, with particular care around its mixed source fields and per-view fallback differences. + +--- + +### CL-2026-06-29-CRM-DISPLAY-RESOLVER-SLICE3: adopt shared CRM display resolver in address search results + +date: 2026-06-29 +author: Cline +scope: `components/search/addresssearchresults.js`, `memory-bank/change-log.md` +type: change +rationale: Continue CRM Display Infrastructure adoption with one additional behavior-preserving read-only search consumer using the existing shared resolver. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/search/addresssearchresults.js` now delegates repeated Welsh CRM display-value lookup logic to the shared resolver for authority, case type, and status labels while preserving local field-source and fallback differences. No CRM query, route, payload, auth/session, or rendering-structure change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `77ae9a6d99d4df1b839aaebdbb1798ce07d1a0d0` +- Selected consumer for Slice 3: + - `components/search/addresssearchresults.js` +- Characterization findings for this consumer: + - English behaviour: renders original CRM formatted/display values directly + - Welsh behaviour: uses JSONPath against `lookuptranslations.json` and renders `value_cy` + - repeated dominant pattern present for: + - authority + - case type + - status + - fallback behaviour: + - where source field exists, English uses original display value or `N/A` + - Welsh falls back to original display value / existing `N/A` path when translation missing + - where source field is absent, rendered value remains empty string + - empty/null handling remains safe through existing `hasOwn(...)` guards and unchanged fallbacks +- Comparison against prior slices: + - matches Slice 1 / Slice 2 dominant resolver pattern overall + - unlike Slice 2, no `.trim()` behaviour was present on status lookup and none was introduced + - unlike Slice 1 and Slice 2 authority lookup, this consumer can render authority from either: + - `_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue` + - `_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue` + - case type in this consumer comes from `item.pinswg_appealType` rather than formatted `pinswg_appealcasetype@...` +- Reused existing shared helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Adopted helper only in the selected consumer and did not modify surrounding rendering structure. + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/search/addresssearchresults.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs`, which still expects legacy route `/api/endpoint/getportalmoduledetails_api` while current repo behaviour uses grouped route `/api/myportal/get-portal-module-details` + - no change made to that unrelated test in this slice + +Follow-ups: + +- Recommended Slice 4: adopt the shared resolver in one further read-only consumer only, likely `components/search/dnssearchresults.js`, while preserving any consumer-specific nuances such as derived labels or alternate display-field sources. + +--- + +### CL-2026-06-29-CRM-DISPLAY-RESOLVER-SLICE2: adopt shared CRM display resolver in search results + +date: 2026-06-29 +author: Cline +scope: `components/search/searchresults.js`, `memory-bank/change-log.md` +type: change +rationale: Continue CRM Display Infrastructure adoption by reusing the existing shared resolver in one additional read-only search consumer with behavior-preserving scope only. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/search/searchresults.js` now delegates repeated Welsh CRM display-value lookup logic to the shared resolver for authority, case type, specialist process, and status labels. No CRM query, route, payload, auth/session, or rendering-structure change intended. +status: completed + +Summary: + +- Continued work on existing branch: + - `feature/crm-display-resolver-slice1` +- Previous commit on branch: + - `3f651c25d4c31972b2c84b872e3ba5f98f34e3ea` +- Selected consumer for Slice 2: + - `components/search/searchresults.js` +- Characterization findings for this consumer: + - English behaviour: renders original CRM formatted/display values directly + - Welsh behaviour: uses JSONPath against `lookuptranslations.json` and renders `value_cy` + - repeated dominant pattern present for: + - authority + - case type + - specialist process + - status + - status lookup trims the source formatted value before Welsh lookup + - fallback behaviour: + - when source field exists, English uses original display value or `N/A` + - Welsh falls back to the original display value / existing `N/A` path when translation missing + - when source field is absent, rendered value remains empty string +- Reused existing shared helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Adopted helper only in the selected consumer and did not modify surrounding rendering structure. + +Validation: + +- Passed: + - `node tests/phase22/crm-display-resolver.test.cjs` + - `npx eslint components/search/searchresults.js lib/i18n/crmDisplay/resolveCrmDisplayValue.js` +- Broader suite run (informational baseline): + - `node tests/phase22/index.test.cjs` + - existing unrelated baseline drift remains in `tests/phase22/case-service-behaviour.test.cjs`, which still expects legacy route `/api/endpoint/getportalmoduledetails_api` while current repo behaviour uses grouped route `/api/myportal/get-portal-module-details` + - no change made to that unrelated test in this slice + +Follow-ups: + +- Recommended Slice 3: adopt the shared resolver in one further read-only consumer only, likely `components/search/addresssearchresults.js`, while preserving any consumer-specific fallback nuances and avoiding bulk migration. + +--- + +### CL-2026-06-29-CRM-DISPLAY-RESOLVER-SLICE1: add shared CRM bilingual display resolver and adopt in admin appeals tab + +date: 2026-06-29 +author: Cline +scope: `lib/i18n/crmDisplay/resolveCrmDisplayValue.js`, `components/admin/tabs/appeals.js`, `tests/phase22/crm-display-resolver.test.cjs`, `memory-bank/change-log.md` +type: change +rationale: Start CRM Display Infrastructure Slice 1 by extracting the dominant CRM formatted-value to Welsh lookup pattern into one small pure helper and adopting it in one low-risk read-only consumer without changing runtime behaviour. +impact: Behaviour-preserving maintainability slice in the CRM Compatibility Model / Presentation Infrastructure area. `components/admin/tabs/appeals.js` now resolves authority, case type, and status labels through one shared helper while preserving English output, Welsh lookuptranslation usage, and per-field fallback behaviour. No CRM query, payload, auth/session, relay hash, route, or accessibility semantics change intended. +status: completed + +Summary: + +- Required context read before implementation: + - `context/business-domain-overview.md` + - `context/architecture.md` + - `context/maintainability-adoption-programme.md` + - `context/implementation-governance.md` + - `GUARDRAILS.md` + - `memory-bank/change-log.md` +- Branch created from latest `origin/SIPS-Development`: + - `feature/crm-display-resolver-slice1` +- Characterized duplicated dominant CRM bilingual display-resolution pattern across the requested candidate consumers: + - `components/search/searchresults.js` + - `components/search/addresssearchresults.js` + - `components/search/dnssearchresults.js` + - `components/myportal/viewall.js` + - `components/admin/tabs/appeals.js` +- Chosen first adoption surface: + - `components/admin/tabs/appeals.js` + - reasons: read-only, smaller blast radius than public search/myportal consumers, clear repeated CRM formatted-value -> locale check -> `lookuptranslations.json` -> `value_cy` pattern, and easy EN/CY comparison for authority / case type / status columns. +- Added shared pure helper: + - `lib/i18n/crmDisplay/resolveCrmDisplayValue.js` + - API: `resolveCrmDisplayValue({ value, locale, translations, fallbackValue })` + - behaviour: + - English returns fallback/original display value unchanged + - Welsh resolves `value_cy` via encapsulated JSONPath lookup + - missing/null/empty values preserve provided fallback behaviour +- Adopted helper only in `components/admin/tabs/appeals.js` for: + - authority label + - case type label + - status label +- Left all other candidate consumers unchanged for later slices. +- Added focused characterization coverage: + - `tests/phase22/crm-display-resolver.test.cjs` + - covers English return, Welsh translated return, Welsh missing-translation fallback, and null/empty/undefined safe handling. +- Audit evidence note: + - the standalone audit file was not found by title during repository search, but the duplicated dominant pattern was directly evidenced in the in-scope candidate consumers listed above and matches the maintainability programme’s cited completed Bilingual CRM Display Resolution Audit. + +Validation: + +- Focused validation intended for this slice: + - `npm run lint` + - `node tests/phase22/crm-display-resolver.test.cjs` + - `node tests/phase22/index.test.cjs` +- Manual validation still required/expected for the adopted consumer: + - English admin appeals tab labels + - Welsh admin appeals tab labels + - lookup hit and lookup miss comparison + - no row/list rendering regression + +Follow-ups: + +- Next recommended slice: adopt the same helper in one additional read-only search-family consumer, likely `components/search/searchresults.js` or `components/search/addresssearchresults.js`, while preserving each consumer’s existing fallback behaviour. + +--- + ### CL-2026-06-29-BUSINESS-DOMAIN-OVERVIEW: clarify PEDW planning-domain terminology and portal business responsibilities date: 2026-06-29 diff --git a/pages/api/endpoint/getdnscoords_api.js b/pages/api/endpoint/getdnscoords_api.js index c6192bf7..131a05fa 100644 --- a/pages/api/endpoint/getdnscoords_api.js +++ b/pages/api/endpoint/getdnscoords_api.js @@ -3,7 +3,7 @@ import OSPoint from "ospoint"; import { respondError, respondSuccess } from "../middleware/apiResponse"; import { relayGetData } from "../middleware/relayForwarding"; import transLookup from "../../../data/lookuptranslations.json"; -import { JSONPath as jsonpath } from "jsonpath-plus"; +import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue"; const renameKeys = (obj) => { const keyMappings = { @@ -132,23 +132,17 @@ const renameKeys = (obj) => { renamedObj.northing = String(renamedObj.northing); } - renamedObj.lpaDisplayName_cy = jsonpath({ - path: - '$..[?(@ && @.value=="' + - renamedObj.lpaDisplayName + - '")].value_cy', - json: transLookup, - eval: true - })[0]; + renamedObj.lpaDisplayName_cy = resolveCrmDisplayValue({ + value: renamedObj.lpaDisplayName, + locale: "cy", + translations: transLookup + }); - renamedObj.statusCodeDescription_cy = jsonpath({ - path: - '$..[?(@ && @.value=="' + - renamedObj.statusCodeDescription + - '")].value_cy', - json: transLookup, - eval: true - })[0]; + renamedObj.statusCodeDescription_cy = resolveCrmDisplayValue({ + value: renamedObj.statusCodeDescription, + locale: "cy", + translations: transLookup + }); return renamedObj; }; diff --git a/pages/api/endpoint/getmylpacases_api.js b/pages/api/endpoint/getmylpacases_api.js index 71a947d9..0ef5bdbf 100644 --- a/pages/api/endpoint/getmylpacases_api.js +++ b/pages/api/endpoint/getmylpacases_api.js @@ -51,14 +51,6 @@ export default async function ApiProxy(req, res) { }); } - //console.log( - // '$..[?(@ && @.name="' + lpaid + '")]', - // lpaList, - // lpaid, - // "LPAGUID=", - // lpaGUID - // ); - const queryUrl = "incidents?$select=pinswg_environmentalstatementlocation,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantlastname,pinswg_appellantfirstname,pinswg_appellantagent,pinswg_agentfirstname,pinswg_agentlastname,pinswg_agentcompanyname&$expand=primarycontactid($select=fullname)&$filter=_pinswg_associatedlpa_value eq " + lpaGUID[0].accountid + diff --git a/pages/myportal/[appealtypes].js b/pages/myportal/[appealtypes].js index 9e1db738..94bfbc68 100644 --- a/pages/myportal/[appealtypes].js +++ b/pages/myportal/[appealtypes].js @@ -1,369 +1,3 @@ -// import fs from "fs"; -// import { JSONPath as jsonpath } from "jsonpath-plus"; -// import useTranslation from "next-translate/useTranslation"; -// import Head from "next/head"; -// import { useRouter } from "next/router"; -// import { useEffect } from "react"; -// import { connect } from "react-redux"; -// import xpath from "xpath"; -// import Breadcrumbs from "../../components/breadcrumbs"; -// import CookieBanner from "../../components/cookieBanner"; -// import Footer from "../../components/footer"; -// import Header from "../../components/header"; -// import BuildCheckSection from "../../components/newappeal/buildchecksection"; -// import BuildSection from "../../components/newappeal/buildsection"; -// import CompleteAppeal from "../../components/newappeal/complete"; -// import TimeOut from "../../components/timeout"; - -// import { getSession } from "next-auth/react"; -// import { -// setContainerID, -// setLoggedInUserEmail, -// setLoggedInUserId, -// setAccountDetails, -// } from "../../store/accountDetails/action"; -// import { -// setAppealLPA, -// setAppealType, -// setAppealTypeID, -// setAppealTypeTitle, -// setCaseReference, -// setFilesForAppeal, -// } from "../../store/appealType/action"; -// import { -// setAwaitingSubmissionDetails, -// setAwaitingSubmissionFromBlob, -// } from "../../store/awaitingSubmission/action"; -// import { setCurrentView, setLocale } from "../../store/currentView/action"; -// import { setForm } from "../../store/formData/action"; -// import { wrapper } from "../../store/store"; -// import ServiceBanner from "../../components/myportal/servicebanner"; - -// let Home = (props) => { -// const { footerLinks, pages, formData } = props; -// let { t, lang } = useTranslation(); - -// const router = useRouter(); -// const { locale } = router; -// const { appealtypes } = router.query; - -// useEffect(() => { -// //setFormTitle(formTitle); -// setCaseReference(router.query.casereference); -// }, []); // eslint-disable-line react-hooks/exhaustive-deps - -// const formXML = props.formData.formData; -// const parser = new DOMParser(); -// var doc = parser.parseFromString(formXML, "text/xml"); -// var titles = xpath.select( -// "//form/tabs/tab[*]/labels/label[@description]/@description", -// doc -// ); -// var sectionCount = xpath.select("/form/tabs/tab[*]", doc); -// sectionCount = sectionCount.length; - -// var tabs = xpath.select("//form/tabs/tab[*]", doc); - -// let optionsStr = props.appealType.appealTypeOptions.value || {}; - -// let selectedObj = jsonpath({ -// path: "$..[?(@ && @.attributevalue=='" + router.query.apt + "')]", -// json: optionsStr, -// eval: true, -// }); - -// //let optionsTitleObj = []; - -// //const optionsTitleObj = selectedObj.reduce( -// // (obj, arrValue) => ( -// // (obj[arrValue] = arrValue -// // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") -// // .toLowerCase() -// // .slice(0, 39)), -// // obj -// // ), -// // {} -// // ); - -// const formTitle = selectedObj[0].value; - -// const { onSubmit } = props; - -// return ( -//
-// -// -// {t("newappeal:page-title")} - {t("common:service-name")} -// -// <> -// -// -// {/* If they have a Twitter Handle, include the meta details below */} -// -// - -// -// -// -// -// -// -// -// -// -// -// -// -// -//
-// -//
- -//
-// -// -//
-// {props.appealType.currentSection == 9999 ? ( -// -// ) : props.appealType.currentSection == -// sectionCount + 1 ? ( -// -// ) : ( -// <> -// -// -// )} -//
-//
-//
-//
-// -//
-// ); -// }; - -// export const getServerSideProps = wrapper.getServerSideProps( -// (store) => async (ctx) => { -// const { query, req, res } = ctx; -// getIP(req); -// const { cookies } = req; - -// console.log("the query", query); -// let loggedInUser = cookies.pinsUser; - -// let thisSession = await getSession(ctx); - -// if (!thisSession) { -// console.log("not has sesssion......."); -// return { -// redirect: { -// destination: "/auth/signin", -// permanent: false, -// }, -// }; -// } - -// console.log(ctx.locale); -// store.dispatch(setLocale(ctx.locale)); - -// let loggedInUserIdent = thisSession.user.id; -// let loggedInUserEmail = thisSession.user.email; - -// //console.log("logged ident:", loggedInUserIdent); - -// console.log("which appeal: ", query.appealtypes); - -// const accountDetails = await getPersonalAccount(loggedInUser); - -// const [appealTypeData, mandatoryFieldsData, pickListData, blobList] = -// await Promise.all([ -// await getAppealsTypesForNewAppeal(), -// await getMandatoryFields(query.appealtypes), -// await getPickLists(query.appealtypes), -// await getFilesFromBlob(loggedInUserIdent, query.casereference), -// ]); - -// const blobProgress = await getProgressFromBlob( -// loggedInUserIdent, -// query.casereference -// ); - -// //console.log("/////////\nappeal type data:", appealTypeData); - -// // -// // Removed to make progress from Blob not CRM -// // - -// // let searchResultsObj = await getPartSavedAppeal(query.casereference); -// // //console.log("eeee:", searchResultsObj); -// // let searchDetailsObj = await getPartSavedDetails(searchResultsObj); - -// // searchDetailsObj = searchDetailsObj[0].value[0]; - -// // Object.keys(searchDetailsObj).forEach((key) => { -// // if (searchDetailsObj[key] === null) { -// // delete searchDetailsObj[key]; -// // } -// // }); - -// //console.log("appeal:", searchDetailsObj); - -// // searchDetailsObj = JSON.stringify(searchDetailsObj); -// // searchDetailsObj = searchDetailsObj.replace(/:true/gm, `:"Yes"`); -// // searchDetailsObj = searchDetailsObj.replace(/:false/gm, `:"No"`); -// // searchDetailsObj = JSON.parse(searchDetailsObj); - -// let caseReference = {}; - -// caseReference.ticketnumber = query.casereference; -// caseReference.incidentid = query.inid; -// caseReference.caseDetails = blobProgress; //searchDetailsObj; - -// var path = require("path"); -// const configDirectory = path.resolve(process.cwd(), "data/formsxml"); -// var xmlStr = fs.readFileSync( -// path.join(configDirectory, query.appealtypes + ".xml"), -// "utf8" -// ); - -// xmlStr = xmlStr.replace(/\t/g, ""); -// xmlStr = xmlStr.replace(/\n/g, ""); -// xmlStr = xmlStr.replace(/> <"/g, "><"); -// xmlStr = xmlStr.toString(); - -// if (query.hasOwnProperty("key")) { -// const awaitingSubmissionFromBlob = -// await getAwaitingSubmissionFromBlob(thisSession.user.id); - -// store.dispatch( -// setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob) -// ); - -// store.dispatch( -// setAwaitingSubmissionDetails(awaitingSubmissionFromBlob) -// ); -// store.dispatch( -// setCurrentView({ -// "viewName": "Awaiting Submission", -// "viewKey": "awaitingSubmissionDetails", -// }) -// ); -// } - -// store.dispatch(setLoggedInUserId(loggedInUser)); -// store.dispatch(setLoggedInUserEmail(loggedInUserEmail)); -// store.dispatch(setAppealLPA(query.lpa)); -// store.dispatch(setAppealTypeID(query.apt)); -// store.dispatch(setCaseReference(caseReference)); -// store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData)); -// store.dispatch(setAppealType(appealTypeData)); -// store.dispatch(setContainerID(thisSession.user.id)); -// store.dispatch(setAccountDetails(accountDetails)); - -// store.dispatch(setFilesForAppeal(blobList)); - -// return { -// props: { url: process.env.NEXTAUTH_URL }, -// }; -// } -// ); - -// const mapStateToProps = (state) => { -// return { -// search: state.search, -// searchResultsObj: state.searchResultsObj, -// formData: state.formData, -// appealType: state.appealType, -// form: state.form, -// accountDetails: state.accountDetails, -// awaitingSubmission: state.awaitingSubmission, -// currentView: state.currentView, -// initialValues: state.appealType.caseReference.caseDetails, -// }; -// }; - -// const mapDispatchToProps = (dispatch) => { -// return { -// setFormTitle: (title) => { -// dispatch(setAppealTypeTitle(title)); -// }, -// setCaseReference: (refno) => { -// dispatch(setCaseReference(refno)); -// }, -// setFilesForAppeal: (blobList) => { -// dispatch(setFilesForAppeal(blobList)); -// }, -// }; -// }; - -// export default connect(mapStateToProps, mapDispatchToProps)(Home); - // pages/myportal/[appealtypes].js import { JSONPath as jsonpath } from "jsonpath-plus"; import xpath from "xpath"; diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js index 23d364cd..d5d4dd2f 100644 --- a/pages/newappeal/[appealtypes].js +++ b/pages/newappeal/[appealtypes].js @@ -1,318 +1,3 @@ -// import fs from "fs"; -// import { JSONPath as jsonpath } from "jsonpath-plus"; -// import useTranslation from "next-translate/useTranslation"; -// import Head from "next/head"; -// import { useRouter } from "next/router"; -// import { useEffect } from "react"; -// import { connect } from "react-redux"; -// import xpath from "xpath"; -// import Breadcrumbs from "../../components/breadcrumbs"; -// import CookieBanner from "../../components/cookieBanner"; -// import Footer from "../../components/footer"; -// import Header from "../../components/header"; -// import BuildCheckSection from "../../components/newappeal/buildchecksection"; -// import BuildSection from "../../components/newappeal/buildsection"; -// import CompleteAppeal from "../../components/newappeal/complete"; -// import TimeOut from "../../components/timeout"; - -// import { getSession } from "next-auth/react"; -// import { -// setContainerID, -// setLoggedInUserEmail, -// setLoggedInUserId, -// setAccountDetails, -// } from "../../store/accountDetails/action"; -// import { -// setAppealLPA, -// setAppealType, -// setAppealTypeID, -// setAppealTypeTitle, -// setCaseReference, -// } from "../../store/appealType/action"; -// import { setForm } from "../../store/formData/action"; -// import { wrapper } from "../../store/store"; -// import ServiceBanner from "../../components/myportal/servicebanner"; - -// let Home = (props) => { -// const { footerLinks, pages, formData } = props; -// let { t, lang } = useTranslation(); - -// const router = useRouter(); -// const { locale } = router; -// const { appealtypes } = router.query; - -// useEffect(() => { -// //setFormTitle(formTitle); -// setCaseReference(router.query.refno); -// }, []); // eslint-disable-line react-hooks/exhaustive-deps - -// const formXML = props.formData.formData; -// const parser = new DOMParser(); -// var doc = parser.parseFromString(formXML, "text/xml"); -// var titles = xpath.select( -// "//form/tabs/tab[*]/labels/label[@description]/@description", -// doc -// ); -// var sectionCount = xpath.select("/form/tabs/tab[*]", doc); -// sectionCount = sectionCount.length; - -// var tabs = xpath.select("//form/tabs/tab[*]", doc); - -// let optionsStr = props.appealType.appealTypeOptions.value; - -// let selectedObj = jsonpath({ -// path: "$..[?(@ && @.attributevalue=='" + router.query.apt + "')]", -// json: optionsStr, -// eval: true, -// }); - -// //let optionsTitleObj = []; - -// //const optionsTitleObj = selectedObj.reduce( -// // (obj, arrValue) => ( -// // (obj[arrValue] = arrValue -// // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") -// // .toLowerCase() -// // .slice(0, 39)), -// // obj -// // ), -// // {} -// // ); - -// const formTitle = selectedObj[0].value; - -// const { onSubmit } = props; - -// return ( -//
-// -// -// {t("newappeal:page-title")} - {t("common:service-name")} -// -// <> -// -// -// {/* If they have a Twitter Handle, include the meta details below */} -// -// - -// -// -// -// -// -// -// -// -// -// -// -// -// -//
-// -//
- -//
-// -// -//
-// {props.appealType.currentSection == 9999 ? ( -// -// ) : props.appealType.currentSection == -// sectionCount + 1 ? ( -// -// ) : ( -// <> -// -// -// )} -//
-//
-//
-//
-// -//
-// ); -// }; - -// export const getServerSideProps = wrapper.getServerSideProps( -// (store) => async (ctx) => { -// const { query, req, res } = ctx; -// getIP(req); -// const { cookies } = req; - -// console.log(cookies); -// console.log("the query", query); -// console.log("ref:", query.id); -// let loggedInUser = cookies.pinsUser; - -// let thisSession = await getSession(ctx); -// //console.log("nextAuth Session:", thisSession); - -// if (!thisSession) { -// console.log("not has sesssion......."); -// return { -// redirect: { -// destination: "/auth/signin", -// permanent: false, -// }, -// }; -// } - -// let loggedInUserIdent = thisSession.user.id; -// let loggedInUserEmail = thisSession.user.email; - -// console.log("logged ident:", loggedInUserIdent, loggedInUserEmail); - -// const [ -// appealTypeData, -// mandatoryFieldsData, -// pickListData, -// //blobList, -// ] = await Promise.all([ -// await getAppealsTypesForNewAppeal(), -// await getMandatoryFields(query.appealtypes), -// await getPickLists(query.appealtypes), - -// //await getFilesFromBlob(query.casereference), -// ]); - -// const blobProgress = await getProgressFromBlob( -// loggedInUserIdent, -// query.id -// ); - -// const accountDetails = await getPersonalAccount(loggedInUser); - -// console.log("anything here", loggedInUser, query.id, blobProgress); - -// let caseReference = {}; - -// caseReference.ticketnumber = query.id; -// caseReference.incidentid = query.id; -// caseReference.caseDetails = blobProgress; //searchDetailsObj; - -// var path = require("path"); -// const configDirectory = path.resolve(process.cwd(), "data/formsxml"); -// var xmlStr = fs.readFileSync( -// path.join(configDirectory, query.appealtypes + ".xml"), -// "utf8" -// ); -// // xmlStr = formdata.value[0].formxml; -// xmlStr = xmlStr.replace(/\t/g, ""); -// xmlStr = xmlStr.replace(/\n/g, ""); -// xmlStr = xmlStr.replace(/> <"/g, "><"); -// xmlStr = xmlStr.toString(); - -// store.dispatch(setLoggedInUserId(loggedInUser)); -// store.dispatch(setLoggedInUserEmail(loggedInUserEmail)); -// store.dispatch(setAppealLPA(query.lpa)); -// store.dispatch(setAppealTypeID(query.apt)); -// store.dispatch(setCaseReference(caseReference)); -// store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData)); -// store.dispatch(setAppealType(appealTypeData)); -// store.dispatch(setContainerID(thisSession.user.id)); -// store.dispatch(setAccountDetails(accountDetails)); - -// //store.dispatch(setFilesForAppeal(blobList)); - -// return { -// props: { url: process.env.NEXTAUTH_URL }, -// }; -// } -// ); - -// const mapStateToProps = (state) => { -// return { -// search: state.search, -// searchResultsObj: state.searchResultsObj, -// formData: state.formData, -// appealType: state.appealType, -// form: state.form, -// accountDetails: state.accountDetails, -// }; -// }; - -// const mapDispatchToProps = (dispatch) => { -// return { -// setFormTitle: (title) => { -// dispatch(setAppealTypeTitle(title)); -// }, -// setCaseReference: (refno) => { -// dispatch(setCaseReference(refno)); -// }, -// }; -// }; - -// export default connect(mapStateToProps, mapDispatchToProps)(Home); - // pages/newappeal/[appealtypes].js import { JSONPath as jsonpath } from "jsonpath-plus"; import xpath from "xpath"; diff --git a/tests/phase22/case-service-behaviour.test.cjs b/tests/phase22/case-service-behaviour.test.cjs index 5c37e232..11ac751e 100644 --- a/tests/phase22/case-service-behaviour.test.cjs +++ b/tests/phase22/case-service-behaviour.test.cjs @@ -30,7 +30,7 @@ test("case/getPortalModuleDetails uses BASE_URL route and encoded case reference assert.deepStrictEqual(normalize(result), { value: [] }); assert.strictEqual( axios.calls[0].url, - "http://example.local/api/endpoint/getportalmoduledetails_api?appealType=appeal&caseReference=REF%20A/B" + "http://example.local/api/myportal/get-portal-module-details?appealType=appeal&caseReference=REF%20A/B" ); }); diff --git a/tests/phase22/crm-display-resolver.test.cjs b/tests/phase22/crm-display-resolver.test.cjs new file mode 100644 index 00000000..ef3d4773 --- /dev/null +++ b/tests/phase22/crm-display-resolver.test.cjs @@ -0,0 +1,181 @@ +const assert = require("assert"); +const fs = require("fs"); +const path = require("path"); +const vm = require("vm"); +const { JSONPath } = require("jsonpath-plus"); + +const tests = []; +const test = (name, fn) => tests.push({ name, fn }); + +const helperModulePath = path.join( + __dirname, + "..", + "..", + "lib", + "i18n", + "crmDisplay", + "resolveCrmDisplayValue.js" +); + +const lookupTranslations = require( + path.join(__dirname, "..", "..", "data", "lookuptranslations.json") +); + +const loadHelper = () => { + const source = fs.readFileSync(helperModulePath, "utf8"); + + const transformedSource = `${source + .replace( + /import\s+\{\s*JSONPath\s+as\s+jsonpath\s*\}\s+from\s+"jsonpath-plus";/, + 'const { JSONPath: jsonpath } = require("jsonpath-plus");' + ) + .replace(/export const /g, "const ") + .replace(/export default resolveCrmDisplayValue;/g, "")} + +module.exports = { + resolveCrmDisplayValue +}; +`; + + const sandbox = { + module: { exports: {} }, + exports: {}, + require: (modulePath) => { + if (modulePath === "jsonpath-plus") { + return { JSONPath }; + } + + return require(modulePath); + }, + __dirname: path.dirname(helperModulePath), + __filename: helperModulePath, + console + }; + + vm.runInNewContext(transformedSource, sandbox, { + filename: helperModulePath + }); + + return sandbox.module.exports; +}; + +test("English with value returns value", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: "Cardiff Council", + locale: "en", + translations: lookupTranslations, + fallbackValue: "Cardiff Council" + }), + "Cardiff Council" + ); +}); + +test("Welsh with translation returns Welsh", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: "Cardiff Council", + locale: "cy", + translations: lookupTranslations, + fallbackValue: "Cardiff Council" + }), + "Cyngor Caerdydd" + ); +}); + +test("Welsh without translation returns English value", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: "Not In Lookup", + locale: "cy", + translations: lookupTranslations, + fallbackValue: "To be confirmed" + }), + "Not In Lookup" + ); +}); + +test("Missing value returns fallback", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + locale: "cy", + translations: lookupTranslations, + fallbackValue: "N/A" + }), + "N/A" + ); +}); + +test("Empty string returns fallback", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: "", + locale: "cy", + translations: lookupTranslations, + fallbackValue: "To be confirmed" + }), + "To be confirmed" + ); +}); + +test("Null returns fallback", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: null, + locale: "cy", + translations: lookupTranslations, + fallbackValue: "To be confirmed" + }), + "To be confirmed" + ); +}); + +test("Undefined returns fallback", () => { + const { resolveCrmDisplayValue } = loadHelper(); + + assert.strictEqual( + resolveCrmDisplayValue({ + value: undefined, + locale: "cy", + translations: lookupTranslations, + fallbackValue: "N/A" + }), + "N/A" + ); +}); + +async function run() { + let failures = 0; + + for (const { name, fn } of tests) { + try { + await fn(); + console.log(`✓ ${name}`); + } catch (error) { + failures += 1; + console.error(`✗ ${name}`); + console.error(error); + } + } + + if (failures > 0) { + process.exitCode = 1; + return; + } + + console.log(`Passed ${tests.length} CRM display resolver tests.`); +} + +run(); diff --git a/tests/phase22/portal-service-behaviour.test.cjs b/tests/phase22/portal-service-behaviour.test.cjs index 26ac9b13..2c847fd6 100644 --- a/tests/phase22/portal-service-behaviour.test.cjs +++ b/tests/phase22/portal-service-behaviour.test.cjs @@ -101,7 +101,7 @@ test("portal/createWatchedCases posts to harmonized route helper URL", async () assert.strictEqual(requestCalls[0].method, "post"); assert.strictEqual( requestCalls[0].url, - "/api/endpoint/createwatchedcases_api" + "/api/subscriptions/create-watched-case" ); assert.deepStrictEqual(normalize(requestCalls[0].data), payload); });