import ReactPDF, { Document, Page, Text, View, Image, StyleSheet, PDFViewer, Font, } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { getFormCollectionByID } from "../../components/utils"; import getT from "next-translate/getT"; import useTranslation from "next-translate/useTranslation"; import transLookupCY from "../../locales/cy/myrepresentations.json"; import transLookupEN from "../../locales/en/myrepresentations.json"; import jsonpath from "jsonpath"; 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, color: "red", 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; let appealTypeValue = getFormCollectionByID(values.appealType); console.log("sdffhjdhjdjdgkj: ", values.procedureType); 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.lpaRef} 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" && ( {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" && ( { values.enterNeighbouringLandToViewSiteEvidence } )} 8. {getTrans( docProps.locale, "s78-section-question-8" )} { values.enterNeighbouringLandAccessRequired } {values.enterNeighbouringLandAccessRequired != "Yes" && ( { values.enterNeighbouringLandAccessRequiredEvidence } )} 9. {getTrans( docProps.locale, "s78-section-question-9" )} {values.healthAndSafetyIssues} {values.healthAndSafetyIssues == "Yes" && ( { values.healthAndSafetyIssuesEvidence } )} 10. {getTrans( docProps.locale, "s78-section-question-10" )} {values.LPAcontactDetails} {getTrans( docProps.locale, "s78-section-heading-two" )} 11. {getTrans( docProps.locale, "s78-section-question-11" )} {values.LPAcaseFileAndReps} 12. {getTrans( docProps.locale, "s78-section-question-12" )} {values.LPAldpAndMap} 13. {getTrans( docProps.locale, "s78-section-question-13" )} {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" && ( {values.ROWEvidence} )} 17. {getTrans( docProps.locale, "s78-section-question-17" )} {values.conservationArea}{" "} {values.conservationArea == "Yes" && ( {values.conservationAreaEvidence} )} 18. {getTrans( docProps.locale, "s78-section-question-18" )} {values.affectListedBuilding} {values.affectListedBuilding == "Yes" && ( { values.affectListedBuildingEvidence } )} 19. {getTrans( docProps.locale, "s78-section-question-19" )} {values.TPO} {values.TPO == "Yes" && ( {values.TPOEvidence} )} 20. {getTrans( docProps.locale, "s78-section-question-20" )} {values.natureConservationSite} {values.natureConservationSite == "Yes" && ( { values.natureConservationSiteEvidence } )} 21. {getTrans( docProps.locale, "s78-section-question-21" )} {values.protectedSpecies} {values.protectedSpecies == "Yes" && ( {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" && ( { values.governmentDepartmentCommentsEvidence } )} {getTrans( docProps.locale, "s78-section-heading-four" )} 24. {getTrans( docProps.locale, "s78-section-question-24" )} a) {getTrans( docProps.locale, "s78-section-question-24a" )} { values.developmentNotBeginLaterThanFiveYears } b) {getTrans( docProps.locale, "s78-section-question-24b" )} { values.developmentCarriedOutInAccordance } {values.developmentCarriedOutInAccordance == "Yes" && ( { values.developmentCarriedOutInAccordanceEvidence } )} c) {getTrans( docProps.locale, "s78-section-question-24c" )} {values.developmentNotTakePlaceBiodiversity} d) {getTrans( docProps.locale, "s78-section-question-24d" )} {values.developmentNotTakePlaceBroadband} 25. {getTrans( docProps.locale, "s78-section-question-25" )} {values.developmentAnyOtherConditions} {values.developmentAnyOtherConditions == "Yes" && ( { values.developmentAnyOtherConditionsEvidence } )} {getTrans( docProps.locale, "s78-section-heading-five" )} 26. {getTrans( docProps.locale, "s78-section-question-26" )} {values.copyOfApplicantsCertificate} { values.copyOfApplicantsCertificateEvidence } 27. {getTrans( docProps.locale, "s78-section-question-27" )} {values.advertismentGiven} {values.advertismentGivenEvidence} 28. {getTrans( docProps.locale, "s78-section-question-28" )} { values.copyOfLetterOfAppealNotification } { values.copyOfLetterOfAppealNotificationEvidence } 29. {getTrans( docProps.locale, "s78-section-question-29" )} {values.lpaEIAOS} {values.lpaEIAOS == "Yes" && ( {values.lpaEIAOSEvidence} )} 30. {getTrans( docProps.locale, "s78-section-question-30" )} { values.advertismentConsentDiscontinuanceNotice } {values.advertismentConsentDiscontinuanceNotice == "Yes" && ( { values.advertismentConsentDiscontinuanceNoticeEvidence } )} 31. {getTrans( docProps.locale, "s78-section-question-31" )} {values.detailsOfOtherAppeals} {values.detailsOfOtherAppeals == "Yes" && ( { values.detailsOfOtherAppealsEvidence } )} 32. {getTrans( docProps.locale, "s78-section-question-32" )} {values.detailsOfPreviousAppeals} {values.detailsOfPreviousAppeals == "Yes" && ( { values.detailsOfPreviousAppealsEvidence } )} 33. {getTrans( docProps.locale, "s78-section-question-33" )} {values.otherRelevantInformation} {values.otherRelevantInformation == "Yes" && ( { 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} - {p.size} ); })} {getTrans(docProps.locale, "s78-footnote-one")} {getTrans(docProps.locale, "s78-footnote-two")}{" "} `${pageNumber} / ${totalPages}` } fixed /> ); };