22500 Phase 1: extract pure helpers from elements index

This commit is contained in:
2026-04-07 09:34:50 +01:00
parent 02512ec403
commit 06b7855826
5 changed files with 252 additions and 174 deletions
@@ -0,0 +1,36 @@
import { JSONPath as jsonpath } from "jsonpath-plus";
export const getFieldTranslation = ({
label,
locale,
appealtypes,
fieldLookup
}) => {
let formObj = jsonpath({
path: "$['" + appealtypes + "']",
json: fieldLookup,
eval: true
});
return locale == "cy"
? jsonpath({
path: '$..[?(@ && @.value=="' + label + '")].value_cy',
json: formObj,
eval: true
})[0]
: label;
};
export const getPickListTranslation = ({
optionValue,
locale,
pickListLookup
}) => {
return locale == "cy"
? jsonpath({
path: '$..[?(@ && @.value=="' + optionValue + '")].value_cy',
json: pickListLookup,
eval: true
})
: optionValue;
};