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
+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" && (