22500 Phase 1: extract pure helpers from elements index
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user