Merged PR 2449: language helper

Related work items: #23754
This commit is contained in:
Robert Bond
2026-07-01 11:29:15 +00:00
parent 49aa258fd9
commit e864049bec
63 changed files with 4008 additions and 6094 deletions
+11 -42
View File
@@ -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
})}
</option>
);
})}
@@ -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
})}
</option>
);
})}
@@ -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) => {
</div>
<div className="cardModuleReference">
<b>{t("myportal:appeal-type-label")}:</b>{" "}
{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
})}
</div>
<div className="cardModuleReference">
<b>{t("myportal:case-address")}:</b>{" "}
@@ -302,20 +294,14 @@ const AwaitingSubmissionFromBlob = (props) => {
{router.locale == "cy" ? "ACLl" : "LPA"}
:
</b>
{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
})}
</div>
<div className="cardModuleReference">
<b>{t("myportal:date-raised")}:</b>
+15 -29
View File
@@ -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) => {
</div>
<div className="cardModuleReference">
<b>{t("myportal:appeal-type-label")}:</b>{" "}
{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
})}
</div>
{/* )} */}
{/* {topThreeType != "awaitingSubmission" ? ( */}
@@ -484,20 +477,13 @@ const TopThree = (props) => {
)}
<div className="cardModuleReference">
<b>{router.locale == "cy" ? "ACLl" : "LPA"}:</b>
{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
})}
</div>
{topThreeType == "awaitingSubmission" ? (
<div className="carModuleAddress">
+18 -75
View File
@@ -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) => {
<b>{showTopThreeArr[key].pinswg_name}</b>
) : (
<span
// href="#"
// href={{
// pathname:
// router.locale == "cy"
// ? "/fymhorth/representation"
// : "/myportal/representation",
// query: {
// case: showTopThreeArr[key].ticketnumber,
// state: "edit",
// created:
// showTopThreeArr[key].repfile_name,
// },
// }}
className="govuk-link--no-underline"
style={{
color: "#0360a6",
@@ -292,54 +279,19 @@ const TopThree = (props) => {
</div>
<div className="cardModuleReference">
<b>{t("myportal:representation-type")}:</b>
{" "}
{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
})}
</div>
<div className="cardModuleReference">
<b>{t("myportal:capacity")}:</b>
{" "}
{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
})}
</div>
<div className="cardModuleReference">
<b>{t("myportal:date-raised")}:</b>
@@ -348,22 +300,13 @@ const TopThree = (props) => {
</div>{" "}
<div className="cardModuleReference">
<b>{router.locale == "cy" ? "ACLl" : "LPA"}:</b>
{" "}
{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
})}
</div>
{showTopThreeArr[key].hasOwnProperty("repComplete") && (
<div className="cardModuleReference">
+80 -140
View File
@@ -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) => {
</span>
{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
})}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
@@ -581,50 +562,36 @@ const ViewAllResults = (props) => {
</span>
{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"
})}
</dd>
{isAwaitingSubmissionDetails && (
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">