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
+29 -53
View File
@@ -29,6 +29,7 @@ import {
deleteWatchedCases,
getWatchedCasesProxy
} from "../../actions/services/portalService";
import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayValue";
import RepsOnResults from "./repsonresults";
import LiveLink from "./liveLink";
@@ -598,39 +599,27 @@ const SearchResults = (props) => {
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) => {
)}
:
</span>
{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"
})}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
<span className="results-visually-hidden">
@@ -675,20 +657,14 @@ const SearchResults = (props) => {
:
</span>
{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>
{myportal == true && (
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">
+48 -105
View File
@@ -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
})}
</option>
);
})}
@@ -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
})}
</option>
);
})}
@@ -456,69 +425,47 @@ let AdvancedSearch = (props) => {
className="govuk-select"
id={id}
name={name}
//onChange={(e) => props.onChangeSelectAppealType(e)}
>
<option value="" disabled defaultValue>
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
: Object.keys(optionsObj).map((key, index) => {
return (
<option
key={key}
value={
_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key]
)
? ""
: _.isEmpty(
optionsObj[key]
.pinswg_sipsprojecttypeid
)
? ""
: optionsObj[key]
.pinswg_sipsprojecttypeid +
"," +
optionsObj[
key
].pinswg_name
.replace(
/(\band|[\s\-\+\(\)\,\&])/g,
""
)
.toLowerCase()
}
>
{_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
optionsObj[key]
.pinswg_name
)
? ""
: router.locale == "cy"
? jsonpath(
'$..[?(@.value=="' +
optionsObj[
key
]
.pinswg_name +
'")].value_cy',
transLookup
)
: optionsObj[key]
.pinswg_name ||
t(
"case:summary-no-date-entered-label"
)}
</option>
);
})}
{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 (
<option
key={key}
value={
projectTypeId && projectName
? `${projectTypeId},${cleanProjectName}`
: ""
}
>
{projectName
? resolveCrmDisplayValue({
value: projectName,
locale,
translations: transLookup
})
: t(
"case:summary-no-date-entered-label"
)}
</option>
);
})}
</select>
</div>
</div>
@@ -595,7 +542,6 @@ let AdvancedSearch = (props) => {
{t("search:search-title-label")}
</h1>
</legend>
<Field
validate={[
minLength(
@@ -620,7 +566,6 @@ let AdvancedSearch = (props) => {
"myportal:searchcases-card-search-example-label-2"
)}
/>
<Field
validate={[
minLength(
@@ -645,7 +590,6 @@ let AdvancedSearch = (props) => {
"myportal:searchcases-card-search-example-label-2"
)}
/>
<Field
name="appealTypes"
id="appealTypes"
@@ -655,7 +599,6 @@ let AdvancedSearch = (props) => {
label={t("search:appealtype-label")}
errormsg="Appeal type is required"
/>
{props.appealTypesValue?.split(
","
)[0] === "846040002" && (
+24 -42
View File
@@ -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"
})
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
@@ -632,20 +620,14 @@ const DNSSearchResults = (props) => {
)}
:
</span>
{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>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
<span className="results-visually-hidden">
+33 -55
View File
@@ -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) => {
)}
:
</span>
{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 && (
<>
<br /> <br />
<span>
{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"
})}
</span>
</>
)}
@@ -694,20 +678,14 @@ const SearchResults = (props) => {
:
</span>
{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"
})}
</dd>
{myportal == true && (
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">