import { Document, Image, Page, StyleSheet, Text, View, Font, } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { getFormCollectionByID, bytesToSize } from "../../components/utils"; import transLookupCY from "../../locales/cy/myrepresentations.json"; import transLookupEN from "../../locales/en/myrepresentations.json"; const getTrans = (locale, key) => { let jsonQuery = `$.${key}`; let jsonObj = locale == "cy" ? transLookupCY : transLookupEN; console.log(locale, jsonObj[key]); return jsonObj[key]; }; 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: "30%", fontSize: 12 }, 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", }, questionAnswerMid: { color: "#757575", width: "20%", fontSize: 12, padding: 5, border: 1, borderColor: "#eee", paddingLeft: 10, backgroundColor: "white", }, questionAnswerWide: { color: "#757575", width: "95%", fontSize: 12, marginLeft: "5%", border: 1, borderColor: "#eee", backgroundColor: "white", padding: 5, }, sectionContainer: { backgroundColor: "#F8F8F8", padding: 10, marginTop: 20, fontSize: 15, }, pageNumber: { position: "absolute", fontSize: 12, bottom: 20, left: 0, right: 0, textAlign: "center", color: "grey", }, richArea: { fontSize: 12, flexDirection: "column", }, }); export const statement_pdf = ({ docProps }) => { console.log("----", docProps); function formatDates(dateObj) { var dateObj = new Date(dateObj); var dd = String(dateObj.getDate()).padStart(2, "0"); var mm = String(dateObj.getMonth() + 1).padStart(2, "0"); //January is 0! var yyyy = dateObj.getFullYear(); return dd + "/" + mm + "/" + yyyy; } let values = docProps; let datestr = values.pinswg_name.split("-"); let signedDate = formatDates(new Date()); // datestr[2] + "/" + datestr[1] + "/" + datestr[0]; let appealTypeValue = getFormCollectionByID(values.appealType); let filterFilesList = values.hasOwnProperty("filesList") ? values.filesList.filter(function (el) { return el != null; }) : []; Font.registerHyphenationCallback((word) => [word]); function CleanHTML(htmlStr) { let cleanStr = typeof htmlStr === "string" ? htmlStr.replace(/


<\/p>/g, "") : ""; return cleanStr; } return ( {getTrans( docProps.locale, "statement-statement-label" )} {/* For Planning, Conservation area, Listed Building and Advertisement applications/appeals */} PEDW Logo {getTrans( docProps.locale, "statement-case-details-header" )} 1. {getTrans( docProps.locale, "s78-section-question-1" )} {values.caseRef} 2. {getTrans( docProps.locale, "statement-representation-capacity-label" )} :{" "} {values.representationCapacity} 3. {getTrans( docProps.locale, "statement-representation-capacity-details-label" )} : {CleanHTML( values.conditional_representationCapacity_Comments )} 4. {getTrans( docProps.locale, "s78-section-question-3" )} {values.siteAddress} 5. {getTrans( docProps.locale, "statement-case-type-label" )} : {appealTypeValue.value || ""} {getTrans( docProps.locale, "statement-comments-header" )} 6. {getTrans( docProps.locale, "statement-statement-label" )} ( {CleanHTML( values.representationComments )} {getTrans( docProps.locale, "statement-supporting-documents-header" )} 7. {getTrans( docProps.locale, "statement-list-of-attached-files-label" )} {values.hasOwnProperty("filesList") && filterFilesList.map(function (p) { return ( {p.name} -{" "} {bytesToSize(p.size)}{" "} {"\n"} ); })} {getTrans( docProps.locale, "statement-declaration-header" )} {getTrans( docProps.locale, "statement-signed-label" )} : {values.firstname} {values.lastname} {getTrans( docProps.locale, "statement-date-label" )} : {signedDate} {values.hasOwnProperty( "representationOnBehalfOf_details" ) ? ( {getTrans( docProps.locale, "statement-onbehalf-label" )} : {values.hasOwnProperty( "representationOnBehalfOf_details" ) ? values.representationOnBehalfOf_details : ""} ) : ( "" )} `${pageNumber} / ${totalPages}` } fixed /> ); };