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 EnforcementQuestionnaire_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("//////////////////////\n docpropseeeee:".docProps);
//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,
"lpa-questionnaire-subheading-enf"
)}
{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,
"enf-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,
"enf-section-question-4"
)}
{values.procedureType}
{values.procedureType !=
"Written representations" && (
{CleanHTML(
values.procedureTypeEvidence
)}
)}
6.
{getTrans(
docProps.locale,
"enf-section-question-5"
)}
{values.enterToView}
7.
{getTrans(
docProps.locale,
"enf-section-question-6"
)}
{values.enterNeighbouringLandToViewSite}
{values.enterNeighbouringLandToViewSite ==
"Yes" && (
{CleanHTML(
values.enterNeighbouringLandToViewSiteEvidence
)}
)}
8.
{getTrans(
docProps.locale,
"enf-section-question-7"
)}
{
values.enterNeighbouringLandAccessRequired
}
{values.enterNeighbouringLandAccessRequired !=
"Yes" && (
{CleanHTML(
values.enterNeighbouringLandAccessRequiredEvidence
)}
)}
9.
{getTrans(
docProps.locale,
"enf-section-question-8"
)}
{values.healthAndSafetyIssues}
{values.healthAndSafetyIssues == "Yes" && (
{CleanHTML(
values.healthAndSafetyIssuesEvidence
)}
)}
10.
{getTrans(
docProps.locale,
"enf-section-question-9"
)}
{CleanHTML(values.LPAcontactDetails)}
{getTrans(
docProps.locale,
"enf-section-heading-two"
)}
11.
{getTrans(
docProps.locale,
"enf-section-question-10"
)}
{values.feePaid}
12.
{getTrans(
docProps.locale,
"enf-section-question-11"
)}
{values.feeExempt}
{values.feeExempt == "Yes" && (
{CleanHTML(
values.feeExemptEvidence
)}
)}
{getTrans(
docProps.locale,
"enf-section-heading-three"
)}
13.
{getTrans(
docProps.locale,
"enf-section-question-12"
)}
{values.previousGrantedCerts}
{values.previousGrantedCerts == "Yes" && (
{CleanHTML(
values.previousGrantedCertsEvidence
)}
)}
14.
{getTrans(
docProps.locale,
"enf-section-question-13"
)}
{values.stopNoticeServed}
{values.stopNoticeServed == "Yes" && (
{CleanHTML(
values.stopNoticeServedEvidence
)}
)}
15.
{getTrans(
docProps.locale,
"enf-section-question-14"
)}
{values.relatedCases}
{values.relatedCases == "Yes" && (
{CleanHTML(values.relatedCasesEvidence)}
)}
16.
{getTrans(
docProps.locale,
"enf-section-question-15"
)}
{values.previousEnforcement}
{values.previousEnforcement == "Yes" && (
{CleanHTML(
values.previousEnforcementEvidence
)}
)}
17.
{getTrans(
docProps.locale,
"enf-section-question-16"
)}
{values.subjectArticle4}
{values.subjectArticle4 == "Yes" && (
{CleanHTML(
values.subjectArticle4Evidence
)}
)}
18.
{getTrans(
docProps.locale,
"enf-section-question-17"
)}
{values.previousPDRRestriction}
{values.previousPDRRestriction == "Yes" && (
{CleanHTML(
values.previousPDRRestrictionEvidence
)}
)}
{getTrans(
docProps.locale,
"enf-section-heading-four"
)}
19.
{getTrans(
docProps.locale,
"enf-section-question-18"
)}
{CleanHTML(values.LPAldpAndMap)}
20.
{getTrans(
docProps.locale,
"enf-section-question-19"
)}
{CleanHTML(values.LPAlocalGuidance)}
21.
{getTrans(
docProps.locale,
"enf-section-question-20"
)}
{values.LPAintentionToSubmitFullStatement}
{getTrans(
docProps.locale,
"enf-section-heading-five"
)}
22.
{getTrans(
docProps.locale,
"enf-section-question-21"
)}
{values.AONB}
23.
{getTrans(
docProps.locale,
"enf-section-question-22"
)}
{values.ROW}
{values.ROW == "Yes" && (
{CleanHTML(values.ROWEvidence)}
)}
24.
{getTrans(
docProps.locale,
"enf-section-question-23"
)}
{values.conservationArea}{" "}
{values.conservationArea == "Yes" && (
{CleanHTML(
values.conservationAreaEvidence
)}
)}
25.
{getTrans(
docProps.locale,
"enf-section-question-24"
)}
{values.affectListedBuilding}
{values.affectListedBuilding == "Yes" && (
{CleanHTML(
values.affectListedBuildingEvidence
)}
)}
26.
{getTrans(
docProps.locale,
"enf-section-question-25"
)}
{values.TPO}
{values.TPO == "Yes" && (
{CleanHTML(values.TPOEvidence)}
)}
27.
{getTrans(
docProps.locale,
"enf-section-question-26"
)}
{values.natureConservationSite}
{values.natureConservationSite == "Yes" && (
{CleanHTML(
values.natureConservationSiteEvidence
)}
)}
28.
{getTrans(
docProps.locale,
"enf-section-question-27"
)}
{values.protectedSpecies}
{values.protectedSpecies == "Yes" && (
{CleanHTML(
values.protectedSpeciesEvidence
)}
)}
29.
{getTrans(
docProps.locale,
"enf-section-question-28"
)}
{values.gypsyTravellerInvolvment}
30.
{getTrans(
docProps.locale,
"enf-section-question-29"
)}
{values.floodingIssue}
{values.floodingIssue == "Yes" && (
{CleanHTML(
values.floodingIssueEvidence
)}
)}
31.
{getTrans(
docProps.locale,
"enf-section-question-30"
)}
{values.governmentDepartmentComments}
{values.governmentDepartmentComments ==
"Yes" && (
{CleanHTML(
values.governmentDepartmentCommentsEvidence
)}
)}
{getTrans(
docProps.locale,
"enf-section-heading-six"
)}
32.
{getTrans(
docProps.locale,
"enf-section-question-31"
)}
a)
{getTrans(
docProps.locale,
"enf-section-question-31a"
)}
{
values.developmentCarriedOutInAccordance
}
{values.developmentCarriedOutInAccordance ==
"Yes" && (
{CleanHTML(
values.developmentCarriedOutInAccordanceEvidence
)}
)}
b)
{getTrans(
docProps.locale,
"enf-section-question-31b"
)}
{values.developmentNotTakePlaceBiodiversity}
c)
{getTrans(
docProps.locale,
"enf-section-question-31c"
)}
{values.developmentNotTakePlaceBroadband}
33.
{getTrans(
docProps.locale,
"enf-section-question-32"
)}
{values.developmentAnyOtherConditions}
{values.developmentAnyOtherConditions ==
"Yes" && (
{CleanHTML(
values.developmentAnyOtherConditionsEvidence
)}
)}
{getTrans(
docProps.locale,
"s78-section-heading-five-sub"
)}
34.
{getTrans(
docProps.locale,
"enf-section-question-33"
)}
{values.copyOfEnforcementNotice}
{CleanHTML(
values.copyOfEnforcementNoticeEvidence
)}
35.
{getTrans(
docProps.locale,
"enf-section-question-34"
)}
{values.enforcementNoticePlan}
{CleanHTML(
values.enforcementNoticePlanEvidence
)}
36.
{getTrans(
docProps.locale,
"enf-section-question-35"
)}
{values.listOfNotifiedOfEnforcement}
{CleanHTML(
values.listOfNotifiedOfEnforcementEvidence
)}
37.
{getTrans(
docProps.locale,
"enf-section-question-36"
)}
{
values.copyOfLetterOfAppealNotification
}
{CleanHTML(
values.copyOfLetterOfAppealNotificationEvidence
)}
38.
{getTrans(
docProps.locale,
"enf-section-question-37"
)}
{values.lpaEIAOS}
{values.lpaEIAOS == "Yes" && (
{CleanHTML(values.lpaEIAOSEvidence)}
)}
39.
{getTrans(
docProps.locale,
"enf-section-question-38"
)}
{values.detailsOfOtherAppeals}
{values.detailsOfOtherAppeals == "Yes" && (
{CleanHTML(
values.detailsOfOtherAppealsEvidence
)}
)}
40.
{getTrans(
docProps.locale,
"enf-section-question-39"
)}
{values.detailsOfPreviousAppeals}
{values.detailsOfPreviousAppeals == "Yes" && (
{CleanHTML(
values.detailsOfPreviousAppealsEvidence
)}
)}
41.
{getTrans(
docProps.locale,
"enf-section-question-40"
)}
{values.otherRelevantInformation}
{values.otherRelevantInformation == "Yes" && (
{CleanHTML(
values.otherRelevantInformationEvidence
)}
)}
{getTrans(
docProps.locale,
"enf-section-heading-eight"
)}
{getTrans(
docProps.locale,
"enf-section-question-signed"
)}
{values.caseOfficer}
{getTrans(
docProps.locale,
"enf-section-question-date"
)}
{formatDates(values.signedDate)}
{getTrans(
docProps.locale,
"enf-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} -{" "}
{bytesToSize(
p.size ||
p.contentLength
)}{" "}
{"\n"}
);
})}
`${pageNumber} / ${totalPages}`
}
fixed
/>
);
};