From 815a8ec818cba3506326c29c539d1af270d5da0a Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 9 May 2024 18:40:51 +0100 Subject: [PATCH] lpa rep pdf tweaks --- components/case/representation/index.js | 58 +++++++++++- .../case/representation/representationLPA.js | 20 ++-- .../representationLPACapacitySelection.js | 2 + ...resentationLPAQuestionnaire_enforcement.js | 17 +--- .../representationLPAQuestionnaire_s78.js | 22 ++--- .../pdftemplates/lpaQuestionnaire_pdf.js | 91 ++++++++----------- .../pdftemplates/planningappeals78_pdf.js | 1 - locales/cy/myrepresentations.json | 1 + locales/en/myrepresentations.json | 3 +- pages/api/file/generatepdf.js | 29 +++--- 10 files changed, 139 insertions(+), 105 deletions(-) diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 8cff8d9e..79425fc0 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -393,6 +393,55 @@ let MakeRepresentation = (props) => { const buildFileArray = []; setSavingStatus(useSaveStatus); + Object.assign(values, { + "containerID": props.props.accountDetails.containerID, + "appealType": props.props.currentView.caseReference.appealType, + "incidentID": props.props.currentView.caseReference.incidentid, + "caseRef": props.props.currentView.caseReference.currentReference, + "pinswg_questionnaireduedate": + detailsObj.pinswg_questionnaireduedate, + "pinswg_statementduedate": detailsObj.pinswg_statementduedate, + "pinswg_finalcommentsduedate": + detailsObj.pinswg_finalcommentsduedate, + "pinswg_name": + props.props.currentView.caseReference.currentReference, + "firstname": props.props.accountDetails.accountDetails.firstname, + "lastname": props.props.accountDetails.accountDetails.lastname, + "emailAddress": + props.props.accountDetails.accountDetails.emailaddress1, + "siteAddress": + detailsObj.pinswg_siteaddressline1 + + " " + + detailsObj.pinswg_siteaddressline2 + + " " + + detailsObj.pinswg_siteaddresstown + + " " + + detailsObj.pinswg_siteaddresspostcode, + "pinswg_siteaddressline1": detailsObj.pinswg_siteaddressline1, + "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, + "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, + "pinswg_siteaddresspostcode": detailsObj.pinswg_siteaddresspostcode, + "_pinswg_appellant_value": detailsObj["_pinswg_appellant_value"], + "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue": + detailsObj[ + "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" + ], + "_pinswg_localplanningauthority_value": + detailsObj["_pinswg_localplanningauthority_value"], + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue": + detailsObj[ + "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" + ], + "representationCapacity": router.query.hasOwnProperty("state") + ? router.query.state == "edit" + ? props.props.currentView.representationCapacity + : values.representationCapacity + : isLPA + ? "lpa" + : values.representationCapacity, + "locale": router.locale, + }); + // "pinswg_name": "2022-11-29-IP-REP_BOND_1", const repDate = new Date(); @@ -525,7 +574,7 @@ let MakeRepresentation = (props) => { router.query.hasOwnProperty("state") && router.query.state == "edit" && - setRepresentationSubmit(true); + setRepresentationSubmit(false); var detailsObj = {}; @@ -609,7 +658,8 @@ let MakeRepresentation = (props) => { ) : questionnaireCount != 0 && showQuestionnaireSection < questionnaireCount - ? setShowQuestionnaireSection(showQuestionnaireSection + 1) + ? (setShowQuestionnaireSection(showQuestionnaireSection + 1), + updateRepresentation(values, false, false)) : setRepresentationSubmit(true) : currentView.representationSubmit == true ? (console.log("capacity", currentView.representationCapacity), @@ -627,6 +677,10 @@ let MakeRepresentation = (props) => { Object.assign(values, { "filesList": buildFileArray, })), + console.log( + "====================== rep lpa payload:\n", + JSON.stringify(values) + ), generateRepPDF( values, props.props.accountDetails.containerID, diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index 76b91eb7..afbe7a7d 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -228,8 +228,11 @@ let RepLPA = (props) => { <>
- {typeof formObj.representationForm.values - .representationType == "undefined" ? ( + {!( + "values" in formObj.representationForm && + "representationType" in + formObj.representationForm.values + ) ? ( <>

{typeof props.representationType != "undefined" @@ -356,6 +359,7 @@ let RepLPA = (props) => { {typeof props.representationType != "undefined" && props.representationType == "Questionnaire" && ( <> + {showQuestionnaireSection} {showQuestionnaireSection <= questionnaireCount && ( // { // Next section // )} - {showQuestionnaireSection == 9 && ( + {showQuestionnaireSection == + questionnaireCount && ( )} {showQuestionnaireSection > 1 && ( @@ -408,7 +416,7 @@ let RepLPA = (props) => { className="govuk-button" data-module="govuk-button" > - {t("common:continue-button")} + {t("common:continue-button")} == { diff --git a/components/case/representation/representationLPACapacitySelection.js b/components/case/representation/representationLPACapacitySelection.js index 342f58fd..03ff11e4 100644 --- a/components/case/representation/representationLPACapacitySelection.js +++ b/components/case/representation/representationLPACapacitySelection.js @@ -30,6 +30,7 @@ let RepLPACapacitySelection = (props) => { capacityOptionsArr, currentType, casesObj, + detailsObj, validate, handleSubmit, } = props; @@ -48,6 +49,7 @@ let RepLPACapacitySelection = (props) => { formObj={formObj} currentType={currentType} casesObj={casesObj} + detailsObj={detailsObj} caseReference={props.props.caseReference} searchResultsObj={props.props.searchResultsObj} props={props.props} diff --git a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js index 7a45f855..31e673fc 100644 --- a/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js +++ b/components/case/representation/representationQuestionnaires/representationLPAQuestionnaire_enforcement.js @@ -819,10 +819,9 @@ let Enforcement_Questionnaire = (props) => { errorMsg={t("newappeal:select-an-option-label")} component={RenderLPACondtionalRadioList} validate={[required]} - legend={ - "a) " + - t("myrepresentations:enf-section-question-31a") - } + legend={t( + "myrepresentations:enf-section-question-31a" + )} conditionalLabel={t( "myrepresentations:enf-section-question-31a-hint" )} @@ -832,10 +831,7 @@ let Enforcement_Questionnaire = (props) => { />

{ aria-describedby={props.name + "-hint"} /> {
{ errorMsg={t("newappeal:select-an-option-label")} component={RenderLPACondtionalRadioList} validate={[required]} - legend={ - "b) " + - t("myrepresentations:s78-section-question-24b") - } + legend={t( + "myrepresentations:s78-section-question-24b" + )} conditionalLabel={t( "myrepresentations:s78-section-question-24b-hint" )} @@ -672,10 +668,7 @@ let S78_Questionnaire = (props) => { /> { validate={[required]} /> { return dd + "/" + mm + "/" + yyyy; } let values = docProps; - console.log("//////////////////////\n docprops:".docProps); + console.log("//////////////////////\n docprops:", docProps); let appealTypeValue = getFormCollectionByID(values.appealType); console.log("sdffhjdhjdjdgkj: ", values.procedureType); @@ -156,7 +155,6 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { alt="PEDW Logo" /> - {getTrans(docProps.locale, "s78-heading-para-two")} @@ -388,9 +386,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { "Yes" && ( - { - values.enterNeighbouringLandAccessRequiredEvidence - } + {values.enterNeighbouringLandAccessRequiredEvidence || + ""} )} @@ -423,9 +420,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.healthAndSafetyIssues == "Yes" && ( - { - values.healthAndSafetyIssuesEvidence - } + {values.healthAndSafetyIssuesEvidence || + ""} )} @@ -461,6 +457,7 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { + { {values.ROW == "Yes" && ( - {values.ROWEvidence} + {values.ROWEvidence || ""} )} @@ -650,7 +647,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.conservationArea == "Yes" && ( - {values.conservationAreaEvidence} + {values.conservationAreaEvidence || + ""} )} @@ -683,9 +681,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.affectListedBuilding == "Yes" && ( - { - values.affectListedBuildingEvidence - } + {values.affectListedBuildingEvidence || + ""} )} @@ -718,7 +715,7 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.TPO == "Yes" && ( - {values.TPOEvidence} + {values.TPOEvidence || ""} )} @@ -751,9 +748,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.natureConservationSite == "Yes" && ( - { - values.natureConservationSiteEvidence - } + {values.natureConservationSiteEvidence || + ""} )} @@ -786,7 +782,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { {values.protectedSpecies == "Yes" && ( - {values.protectedSpeciesEvidence} + {values.protectedSpeciesEvidence || + ""} )} @@ -838,9 +835,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { "Yes" && ( - { - values.governmentDepartmentCommentsEvidence - } + {values.governmentDepartmentCommentsEvidence || + ""} )} @@ -928,9 +924,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { "Yes" && ( - { - values.developmentCarriedOutInAccordanceEvidence - } + {values.developmentCarriedOutInAccordanceEvidence || + ""} )} @@ -1000,9 +995,8 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { "Yes" && ( - { - values.developmentAnyOtherConditionsEvidence - } + {values.developmentAnyOtherConditionsEvidence || + ""} )} @@ -1051,13 +1045,11 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { - { - values.copyOfApplicantsCertificateEvidence - } + {values.copyOfApplicantsCertificateEvidence || + ""} - { - {values.advertismentGivenEvidence} + {values.advertismentGivenEvidence || ""} - { - { - values.copyOfLetterOfAppealNotificationEvidence - } + {values.copyOfLetterOfAppealNotificationEvidence || + ""} - { {values.lpaEIAOS == "Yes" && ( - {values.lpaEIAOSEvidence} + {values.lpaEIAOSEvidence || ""} )} - { "Yes" && ( - { - values.advertismentConsentDiscontinuanceNoticeEvidence - } + {values.advertismentConsentDiscontinuanceNoticeEvidence || + ""} )} - { {values.detailsOfOtherAppeals == "Yes" && ( - { - values.detailsOfOtherAppealsEvidence - } + {values.detailsOfOtherAppealsEvidence || + ""} )} - { {values.detailsOfPreviousAppeals == "Yes" && ( - { - values.detailsOfPreviousAppealsEvidence - } + {values.detailsOfPreviousAppealsEvidence || + ""} )} - { {values.otherRelevantInformation == "Yes" && ( - { - values.otherRelevantInformationEvidence - } + {values.otherRelevantInformationEvidence || + ""} )} diff --git a/components/pdftemplates/planningappeals78_pdf.js b/components/pdftemplates/planningappeals78_pdf.js index 6afe6357..9ec3f81a 100644 --- a/components/pdftemplates/planningappeals78_pdf.js +++ b/components/pdftemplates/planningappeals78_pdf.js @@ -8,7 +8,6 @@ import ReactPDF, { PDFViewer, Font, } from "@react-pdf/renderer"; -import { createElement } from "react"; import Html from "react-pdf-html"; import { getFormCollectionByID, bytesToSize } from "../utils"; import fs from "fs"; diff --git a/locales/cy/myrepresentations.json b/locales/cy/myrepresentations.json index d6f2c39f..60419200 100644 --- a/locales/cy/myrepresentations.json +++ b/locales/cy/myrepresentations.json @@ -97,6 +97,7 @@ "s78-section-question-32-hint": "Os Oes, rhowch y rhif(au) cyfeirnod a’r cyfeiriad(au) ac atodwch neu mewnosodwch ddolenni i’r penderfyniad(au) ac unrhyw ddogfennau cais perthnasol", "s78-section-question-33": "Unrhyw wybodaeth berthnasol arall y dylem wybod amdani?", "s78-section-question-33-hint": "Os Oes, rhowch ddisgrifiad byr ac atodwch neu mewnosodwch ddolenni i'r manylion perthnasol", + "s78-section-heading-six": "Ychwanegu eich ffeiliau", "s78-section-heading-seven": "Datganiad", "s78-section-question-signed": "Llofnodwyd", "s78-section-question-onbehalf": "Ar ran", diff --git a/locales/en/myrepresentations.json b/locales/en/myrepresentations.json index e01df468..735bd925 100644 --- a/locales/en/myrepresentations.json +++ b/locales/en/myrepresentations.json @@ -87,7 +87,7 @@ "s78-section-question-27-hint": "Insert weblink here if available online. If No, give reasons", "s78-section-question-28": "A copy of the letter with which you notified people of the appeal AND a list of the people you notified?", "s78-section-question-28-hint": "Insert weblink here if available online. If No, give reasons", - "s78-section-question-29": "he LPA’s Environmental Impact Assessment Screening Opinion, if applicable?", + "s78-section-question-29": "The LPA’s Environmental Impact Assessment Screening Opinion, if applicable?", "s78-section-question-29-hint": "Insert weblink here if available online. If No, give reasons", "s78-section-question-30": "Advertisement consent proposals only: A true copy of the Discontinuance Notice (if one has been issued)?", "s78-section-question-30-hint": "If Yes, state how the use of the site or the display of the advertisement(s) enjoys the benefit of deemed consent", @@ -97,6 +97,7 @@ "s78-section-question-32-hint": "If Yes, provide the reference number(s) and address(es) and attach or insert links to the decision(s) and any relevant application documents", "s78-section-question-33": "Any other relevant information that we should know about?", "s78-section-question-33-hint": "If Yes, provide a brief description and attach or insert links to the relevant details", + "s78-section-heading-six": "Add your files", "s78-section-heading-seven": "Declaration", "s78-section-question-signed": "Signed", "s78-section-question-onbehalf": "On behalf of", diff --git a/pages/api/file/generatepdf.js b/pages/api/file/generatepdf.js index b021c8bf..ed1643f7 100644 --- a/pages/api/file/generatepdf.js +++ b/pages/api/file/generatepdf.js @@ -116,7 +116,7 @@ export default async function handler(req, res) { ); console.log( "//////////////////////\nreqBodyobj" + - req.body + + JSON.stringify(req.body) + "\n//////////////////////\n" ); @@ -227,16 +227,21 @@ export default async function handler(req, res) { containerID, caseRef, reqBodyobj.repfile_name - ).then((data) => { - console.log( - "///////////////////////////////////\nrep pdf file created: " + - `${caseRef}/files/${reqBodyobj.repfile_name}.pdf`, - "\n/////////////////////////" - ); - return res.status(200).json({ - status: "success", - data: data, - path: `${caseRef}/${reqBodyobj.repfile_name}/files/${reqBodyobj.repfile_name}.pdf`, + ) + .then((data) => { + console.log( + "///////////////////////////////////\nrep pdf file created: " + + `${caseRef}/files/${reqBodyobj.repfile_name}.pdf`, + "\n/////////////////////////" + ); + return res.status(200).json({ + status: "success", + data: data, + path: `${caseRef}/${reqBodyobj.repfile_name}/files/${reqBodyobj.repfile_name}.pdf`, + }); + }) + .catch((err) => { + console.log(consoleLogger(err)); + res.status(400).json(err); }); - }); }