welsh downloadable new appeal form
This commit is contained in:
@@ -4,7 +4,8 @@ import xpath from "xpath";
|
||||
import {
|
||||
bytesToSize,
|
||||
getPickListLabel,
|
||||
getDocumentTypeFromFilename
|
||||
getDocumentTypeFromFilename,
|
||||
getFormCollectionByID
|
||||
} from "../../components/utils";
|
||||
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
|
||||
|
||||
@@ -15,6 +16,7 @@ import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
|
||||
|
||||
export const AppealRow_pdf = (props) => {
|
||||
let { t } = useTranslation();
|
||||
let locale = props.props.locale;
|
||||
|
||||
const {
|
||||
formXML,
|
||||
@@ -146,18 +148,32 @@ export const AppealRow_pdf = (props) => {
|
||||
return dateString;
|
||||
}
|
||||
|
||||
const FieldsTranslations = (label) => {
|
||||
const { appealtypes } = router.query;
|
||||
const FieldsTranslations = (label, locale) => {
|
||||
const appealtypes = getFormCollectionByID(
|
||||
props.props.caseObj.pinswg_appealcasetype
|
||||
).UrlName;
|
||||
|
||||
let formObj = jsonpath({
|
||||
path: "$['" + appealtypes + "']",
|
||||
const formObj = jsonpath({
|
||||
path: `$['${appealtypes}'].[?(@.value=="${label}")]`,
|
||||
json: fieldLookup,
|
||||
eval: true
|
||||
});
|
||||
|
||||
let labelTrans = label;
|
||||
return labelTrans;
|
||||
const item = formObj?.[0];
|
||||
|
||||
if (locale === "cy" && !item?.value_cy) {
|
||||
console.warn(`[Missing Welsh translation]`, {
|
||||
label: item?.value,
|
||||
orig: label,
|
||||
appealType: appealtypes
|
||||
});
|
||||
}
|
||||
|
||||
return locale === "cy"
|
||||
? (item?.value_cy ?? item?.value ?? label)
|
||||
: (item?.value ?? label);
|
||||
};
|
||||
|
||||
Font.registerHyphenationCallback((word) => [word]);
|
||||
|
||||
function CleanHTML(htmlStr) {
|
||||
@@ -219,8 +235,10 @@ export const AppealRow_pdf = (props) => {
|
||||
<Text
|
||||
style={styles.questionTextWide}
|
||||
>
|
||||
{/* {FieldsTranslations(rows[0].value)} */}
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}{" "}
|
||||
</Text>
|
||||
|
||||
<Text
|
||||
@@ -260,7 +278,10 @@ export const AppealRow_pdf = (props) => {
|
||||
styles.questionTextMid
|
||||
}
|
||||
>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
@@ -335,7 +356,10 @@ export const AppealRow_pdf = (props) => {
|
||||
styles.questionTextWide
|
||||
}
|
||||
>
|
||||
{rows[0].value}{" "}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}{" "}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
@@ -368,7 +392,10 @@ export const AppealRow_pdf = (props) => {
|
||||
styles.questionTextWide
|
||||
}
|
||||
>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
@@ -399,7 +426,10 @@ export const AppealRow_pdf = (props) => {
|
||||
>
|
||||
<Text style={styles.questionText}>
|
||||
{/* {FieldsTranslations(rows[0].value)} */}
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
<Text style={styles.questionAnswer}>
|
||||
{getPickListLabel(
|
||||
@@ -453,7 +483,10 @@ export const AppealRow_pdf = (props) => {
|
||||
styles.questionTextWide
|
||||
}
|
||||
>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -524,7 +557,10 @@ export const AppealRow_pdf = (props) => {
|
||||
styles.questionTextMid
|
||||
}
|
||||
>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
@@ -638,7 +674,10 @@ export const AppealRow_pdf = (props) => {
|
||||
style={styles.questionText}
|
||||
wrap={false}
|
||||
>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
<Text
|
||||
style={
|
||||
@@ -665,7 +704,10 @@ export const AppealRow_pdf = (props) => {
|
||||
}}
|
||||
>
|
||||
<Text style={styles.questionText}>
|
||||
{rows[0].value}
|
||||
{FieldsTranslations(
|
||||
rows[0].value,
|
||||
locale
|
||||
)}
|
||||
</Text>
|
||||
<Text style={styles.questionAnswer}>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user