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: "75%", fontSize: 12, marginRight: 10 }, questionTextWide: { width: "95%", fontSize: 12, marginBottom: 5 }, questionAnswer: { color: "#757575", width: "65%", fontSize: 12, padding: 5, border: 1, borderColor: "#eee", paddingLeft: 10, backgroundColor: "white", }, questionAnswerSmall: { color: "#757575", width: "300", fontSize: 12, padding: 5, border: 1, borderColor: "#eee", paddingLeft: 10, paddingRight: 10, backgroundColor: "white", marginRight: 10, }, questionAnswerSmaller: { color: "#757575", width: "90", 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: "100%", fontSize: 12, border: 1, borderColor: "#eee", backgroundColor: "white", padding: 5, }, questionAnswerFull: { color: "#757575", width: "100%", fontSize: 10, padding: 5, border: 1, borderColor: "#eee", backgroundColor: "white", }, 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 lpaQuestionnaire_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; //console.log("//////////////////////\n docprops:", docProps); let appealTypeValue = getFormCollectionByID(values.appealType); //console.log("sdffhjdhjdjdgkj: ", values.procedureType); Font.registerHyphenationCallback((word) => [word]); function CleanHTML(htmlStr) { let cleanStr = typeof htmlStr === "string" ? htmlStr.replace( /


<\/p>|


<\/p>/g, "" ) : ""; return cleanStr; } return ( {getTrans( docProps.locale, "lpa-questionnaire-heading" )} {getTrans( docProps.locale, "s78-heading-para-one" )} PEDW Logo {getTrans(docProps.locale, "s78-heading-para-two")} {getTrans( docProps.locale, "section-heading-zero" )} 1. {getTrans( docProps.locale, "s78-section-question-1" )} {values.caseRef} 2. {getTrans( docProps.locale, "s78-section-question-2" )} {values.pinswg_lpareference || " "} 3. {getTrans( docProps.locale, "s78-section-question-3" )} {values.siteAddress} 4. {getTrans( docProps.locale, "s78-section-question-4" )} {appealTypeValue.value} {getTrans( docProps.locale, "s78-section-heading-one" )} 5. {getTrans( docProps.locale, "s78-section-question-5" )} {values.procedureType} {values.procedureType != "Written representations" && ( {CleanHTML( values.procedureTypeEvidence )} )} 6. {getTrans( docProps.locale, "s78-section-question-6" )} {values.enterToView} 7. {getTrans( docProps.locale, "s78-section-question-7" )} {values.enterNeighbouringLandToViewSite || " "} {values.enterNeighbouringLandToViewSite == "Yes" && ( {CleanHTML( values.enterNeighbouringLandToViewSiteEvidence )} )} 8. {getTrans( docProps.locale, "s78-section-question-8" )} {values.enterNeighbouringLandAccessRequired || " "} {values.enterNeighbouringLandAccessRequired != "Yes" && ( {CleanHTML( values.enterNeighbouringLandAccessRequiredEvidence )} )} 9. {getTrans( docProps.locale, "s78-section-question-9" )} {values.healthAndSafetyIssues} {values.healthAndSafetyIssues == "Yes" && ( {CleanHTML( values.healthAndSafetyIssuesEvidence )} )} 10. {getTrans( docProps.locale, "s78-section-question-10" )} {CleanHTML(values.LPAcontactDetails)} {getTrans( docProps.locale, "s78-section-heading-two" )} 11. {getTrans( docProps.locale, "s78-section-question-11" )} {CleanHTML(values.LPAcaseFileAndReps)} 12. {getTrans( docProps.locale, "s78-section-question-12" )} {CleanHTML(values.LPAldpAndMap)} 13. {getTrans( docProps.locale, "s78-section-question-13" )} {CleanHTML(values.LPAlocalGuidance)} 14. {getTrans( docProps.locale, "s78-section-question-14" )} {values.LPAintentionToSubmitFullStatement || ""} {getTrans( docProps.locale, "s78-section-heading-three" )} 15. {getTrans( docProps.locale, "s78-section-question-15" )} {values.AONB} 16. {getTrans( docProps.locale, "s78-section-question-16" )} {values.ROW} {values.ROW == "Yes" && ( {CleanHTML(values.ROWEvidence)} )} 17. {getTrans( docProps.locale, "s78-section-question-17" )} {values.conservationArea}{" "} {values.conservationArea == "Yes" && ( {CleanHTML( values.conservationAreaEvidence )} )} 18. {getTrans( docProps.locale, "s78-section-question-18" )} {values.affectListedBuilding} {values.affectListedBuilding == "Yes" && ( {CleanHTML( values.affectListedBuildingEvidence )} )} 19. {getTrans( docProps.locale, "s78-section-question-19" )} {values.TPO} {values.TPO == "Yes" && ( {CleanHTML(values.TPOEvidence)} )} 20. {getTrans( docProps.locale, "s78-section-question-20" )} {values.natureConservationSite} {values.natureConservationSite == "Yes" && ( {CleanHTML( values.natureConservationSiteEvidence )} )} 21. {getTrans( docProps.locale, "s78-section-question-21" )} {values.protectedSpecies} {values.protectedSpecies == "Yes" && ( {CleanHTML( values.protectedSpeciesEvidence )} )} 22. {getTrans( docProps.locale, "s78-section-question-22" )} {values.gypsyTravellerInvolvment} 23. {getTrans( docProps.locale, "s78-section-question-23" )} {values.governmentDepartmentComments} {values.governmentDepartmentComments == "Yes" && ( {CleanHTML( values.governmentDepartmentCommentsEvidence )} )} {getTrans( docProps.locale, "s78-section-heading-four" )} 24. {getTrans( docProps.locale, "s78-section-question-24" )} {getTrans( docProps.locale, "s78-section-question-24a" )} { values.developmentNotBeginLaterThanFiveYears } {getTrans( docProps.locale, "s78-section-question-24b" )} { values.developmentCarriedOutInAccordance } {values.developmentCarriedOutInAccordance == "Yes" && ( {CleanHTML( values.developmentCarriedOutInAccordanceEvidence )} )} {getTrans( docProps.locale, "s78-section-question-24c" )} {values.developmentNotTakePlaceBiodiversity} {getTrans( docProps.locale, "s78-section-question-24d" )} {values.developmentNotTakePlaceBroadband} 25. {getTrans( docProps.locale, "s78-section-question-25" )} {values.developmentAnyOtherConditions} {values.developmentAnyOtherConditions == "Yes" && ( {CleanHTML( values.developmentAnyOtherConditionsEvidence )} )} {getTrans( docProps.locale, "s78-section-heading-five-sub" )} 26. {getTrans( docProps.locale, "s78-section-question-26" )} {values.copyOfApplicantsCertificate} {values.hasOwnProperty( "copyOfApplicantsCertificateEvidence" ) && ( {CleanHTML( values.copyOfApplicantsCertificateEvidence )} )} 27. {getTrans( docProps.locale, "s78-section-question-27" )} {values.advertismentGiven} {values.hasOwnProperty( "advertismentGivenEvidence" ) && ( {CleanHTML( values.advertismentGivenEvidence )} )} 28. {getTrans( docProps.locale, "s78-section-question-28" )} { values.copyOfLetterOfAppealNotification } {values.hasOwnProperty( "copyOfLetterOfAppealNotificationEvidence" ) && ( {CleanHTML( values.copyOfLetterOfAppealNotificationEvidence )} )} 29. {getTrans( docProps.locale, "s78-section-question-29" )} {values.lpaEIAOS} {values.lpaEIAOS == "Yes" && ( {CleanHTML(values.lpaEIAOSEvidence)} )} 30. {getTrans( docProps.locale, "s78-section-question-30" )} { values.advertismentConsentDiscontinuanceNotice } {values.advertismentConsentDiscontinuanceNotice == "Yes" && ( {CleanHTML( values.advertismentConsentDiscontinuanceNoticeEvidence )} )} 31. {getTrans( docProps.locale, "s78-section-question-31" )} {values.detailsOfOtherAppeals} {values.detailsOfOtherAppeals == "Yes" && ( {CleanHTML( values.detailsOfOtherAppealsEvidence )} )} 32. {getTrans( docProps.locale, "s78-section-question-32" )} {values.detailsOfPreviousAppeals} {values.detailsOfPreviousAppeals == "Yes" && ( {CleanHTML( values.detailsOfPreviousAppealsEvidence )} )} 33. {getTrans( docProps.locale, "s78-section-question-33" )} {values.otherRelevantInformation} {values.otherRelevantInformation == "Yes" && ( {CleanHTML( values.otherRelevantInformationEvidence )} )} {" "} {getTrans( docProps.locale, "s78-section-heading-seven" )} {getTrans( docProps.locale, "s78-section-question-signed" )} {values.caseOfficer} {getTrans( docProps.locale, "s78-section-question-date" )} {formatDates(values.signedDate)} {getTrans( docProps.locale, "s78-section-question-onbehalf" )} {values.onBehalfOfLPA} {getTrans( docProps.locale, "lpa-list-supporting-documents-heading" )} {getTrans( docProps.locale, "lpa-list-supporting-documents-list" )} {values.hasOwnProperty("filesList") && values.filesList.map(function (p) { return ( {p.name} {"\n"}( {bytesToSize( p.contentLength || p.size )} ){" "} ); })} {/* {getTrans(docProps.locale, "s78-footnote-one")} {getTrans(docProps.locale, "s78-footnote-two")}{" "} */} `${pageNumber} / ${totalPages}` } fixed /> ); };