import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import xpath from "xpath"; import { bytesToSize, getPickListLabel, getDocumentTypeFromFilename, } from "../../components/utils"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import { StyleSheet, Text, View, Font } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { DOMParser, XMLSerializer } from "@xmldom/xmldom"; export const AppealRow_pdf = (props) => { let { t } = useTranslation(); const { formXML, whichSection, sectionCount, onSubmit, updateCurrentSection, mandatoryFieldsData, } = props; const styles = StyleSheet.create({ page: { backgroundColor: "white", padding: 20, fontSize: 16, paddingBottom: 50, }, header: { fontSize: 25, fontFamily: "Helvetica", flexDirection: "row", justifyContent: "space-between", }, subHeader: { fontSize: 20, }, logoImage: { width: "200pt" }, questionBullet: { width: "5%", fontSize: 12 }, questionText: { width: "35%", fontSize: 12, marginRight: 5, }, questionTextMid: { width: "80%", fontSize: 12 }, questionTextWide: { width: "95%", fontSize: 12, marginBottom: 5 }, questionAnswer: { color: "#757575", width: "65%", fontSize: 12, padding: 5, border: 1, borderColor: "#eee", paddingLeft: 10, backgroundColor: "white", display: "flex", flexWrap: "wrap", }, questionAnswerMid: { color: "#757575", width: "20%", fontSize: 12, padding: 5, border: 1, borderColor: "#eee", paddingLeft: 10, backgroundColor: "white", display: "flex", flexWrap: "wrap", }, questionAnswerWide: { color: "#757575", width: "100%", fontSize: 12, border: 1, borderColor: "#eee", backgroundColor: "white", padding: 5, }, questionAnswerRow: { width: "100%", flex: 1, flexDirection: "row", flexGrow: 1, }, questionAnswerColLeft: { width: "40%", }, questionAnswerColRight: { padding: 5, width: "40%", }, sectionContainer: { backgroundColor: "#F8F8F8", padding: 10, marginTop: 20, fontSize: 15, }, pageNumber: { position: "absolute", fontSize: 12, bottom: 20, left: 0, right: 0, textAlign: "center", color: "grey", }, documentList: { fontSize: 10, }, richArea: { fontSize: 12, flexDirection: "column", }, }); const parser = new DOMParser(); var doc = parser.parseFromString(formXML, "text/xml"); var rowXML = xpath.select( "/form/tabs/tab[" + whichSection + "]/columns//sections/section/rows/row", doc ); function formatDate(dateObj) { var m = new Date(dateObj); var dateString; dateObj != null ? (dateString = ("0" + m.getDate()).slice(-2) + "/" + ("0" + (m.getMonth() + 1)).slice(-2) + "/" + m.getFullYear()) : (dateString = ""); return dateString; } const FieldsTranslations = (label) => { const { appealtypes } = router.query; let formObj = jsonpath({ path: "$['" + appealtypes + "']", json: fieldLookup, eval: true, }); let labelTrans = label; return labelTrans; }; Font.registerHyphenationCallback((word) => [word]); function CleanHTML(htmlStr) { let cleanStr = typeof htmlStr === "string" ? htmlStr.replace( /
<\/p>|
<\/p>/g,
""
)
: "";
return cleanStr;
}
return (
<>
{Object.keys(rowXML).map((key, index) => {
var newRowXML = new XMLSerializer().serializeToString(
rowXML[key]
);
var doc = parser.parseFromString(newRowXML, "text/xml");
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
var datafieldcontent = xpath.select("//@datafieldcontent", doc);
var parentField = xpath.select("//@parentField", doc);
var parentFieldShowOnValue = xpath.select(
"//@parentFieldShowOnValue",
doc
);
var documentTypeCode = xpath.select(
"//@ishareDocumentCode",
doc
);
return (
<>
{(() => {
switch (fieldtype[0].value) {
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
return (