Merged PR 1347: multiple reps fixes

Related work items: #12915
This commit is contained in:
Robert Bond
2025-01-02 13:36:58 +00:00
14 changed files with 295 additions and 39 deletions
+4 -6
View File
@@ -179,7 +179,6 @@ let MakeRepresentation = (props) => {
("0" + repDate.getMinutes()).slice(-2) +
":" +
("0" + repDate.getSeconds()).slice(-2) +
":" +
"_-_" +
repCap +
"_-_" +
@@ -752,9 +751,8 @@ let MakeRepresentation = (props) => {
props.props.accountDetails.accountDetails.emailaddress1,
"siteAddress":
detailsObj.pinswg_siteaddressline1 +
" " +
detailsObj.pinswg_siteaddressline2 +
" " +
(detailsObj.pinswg_siteaddressline2 != null &&
" " + detailsObj.pinswg_siteaddressline2 + " ") +
detailsObj.pinswg_siteaddresstown +
" " +
detailsObj.pinswg_siteaddresspostcode,
@@ -956,8 +954,8 @@ let MakeRepresentation = (props) => {
props.props.accountDetails.accountDetails.emailaddress1,
"siteAddress":
detailsObj.pinswg_siteaddressline1 +
" " +
detailsObj.pinswg_siteaddressline2 +
(detailsObj.pinswg_siteaddressline2 != null &&
" " + detailsObj.pinswg_siteaddressline2 + " ") +
" " +
detailsObj.pinswg_siteaddresstown +
" " +
@@ -7,7 +7,7 @@ import { connect } from "react-redux";
import RepComplete from "./representationComplete";
import RepLPAQuestionnaireCheck_enforcement from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement";
import RepLPAQuestionnaireCheck_s78 from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78";
import Link from "next/link";
import { bytesToSize, getThumbnailIconByExtension } from "../../utils";
const RepCompleteSubmit = (props) => {
@@ -90,7 +90,7 @@ const RepCompleteSubmit = (props) => {
// "caseRef": props.props.currentView.caseReference.currentReference,
// });
console.log("///////// repFormData:", repFormData);
//console.log("///////// repFormData:", repFormData);
const whichQuestionnaireCheck = () => {
{
@@ -153,10 +153,10 @@ const RepCompleteSubmit = (props) => {
});
}
console.log(
buildAppealFilesArray,
formObj.representationForm.values.filesList
);
// console.log(
// buildAppealFilesArray,
// formObj.representationForm.values.filesList
// );
// buildAppealFilesArray = formObj.representationForm.values.hasOwnProperty(
// "filesList"
@@ -438,7 +438,13 @@ const RepCompleteSubmit = (props) => {
<p>
{t(
"myrepresentations:rep-check-tandc-para-two"
)}
)}{" "}
<Link href={t("common:footer-privacy-link")}>
{t(
"common:footer-privacy-notice-link-label"
)}
</Link>
.
</p>
<p>
@@ -287,9 +287,8 @@ export const RenderCondtionalRadioList = ({
</legend>
<div id={id + "-hint"} className="govuk-hint">
e.g. &lsquo;Owners of Numbers 1-5 High Street&lsquo;, or
&lsquo;Mr and Mrs Smith&lsquo; or &lsquo;The executors
of Mr Evans&lsquo; estate&lsquo;
e.g. "Owners of Numbers 1-5 High Street", or "Mr and Mrs
Smith" or "The executors of Mr Evans" estate"
</div>
<div className="govuk-radios">
{Object.keys(options).map((key, index) => (
@@ -334,7 +333,7 @@ export const RenderCondtionalRadioList = ({
htmlFor={id + "_details"}
>
Enter the name of the
company/group/organisation *
company/group/organisation
</label>
<Field
className="govuk-input govuk-!-width-one-half"
@@ -114,9 +114,10 @@ let Enforcement_Questionnaire = (props) => {
<div className="govuk-label">
3. {t("myrepresentations:enf-section-question-3")}:{" "}
{detailsObj.pinswg_siteaddressline1 +
" " +
detailsObj.pinswg_siteaddressline2 +
" " +
(detailsObj.pinswg_siteaddressline2 != null &&
" " +
detailsObj.pinswg_siteaddressline2 +
" ") +
detailsObj.pinswg_siteaddresstown +
" " +
detailsObj.pinswg_siteaddresspostcode}
@@ -134,9 +134,10 @@ let S78_Questionnaire = (props) => {
<div className="govuk-label">
3. {t("myrepresentations:s78-section-question-3")}{" "}
{detailsObj.pinswg_siteaddressline1 +
" " +
detailsObj.pinswg_siteaddressline2 +
" " +
(detailsObj.pinswg_siteaddressline2 != null &&
" " +
detailsObj.pinswg_siteaddressline2 +
" ") +
detailsObj.pinswg_siteaddresstown +
" " +
detailsObj.pinswg_siteaddresspostcode}
+7 -3
View File
@@ -112,8 +112,13 @@ export const finalComments_pdf = ({ docProps }) => {
let values = docProps;
let datestr = values.repfile_name.split("-");
let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0];
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;
})
: [];
return (
<Document>
@@ -127,7 +132,6 @@ export const finalComments_pdf = ({ docProps }) => {
fontFamily: "Helvetica-Bold",
}}
>
F
{getTrans(
docProps.locale,
"final-comments-label"
@@ -359,7 +363,7 @@ export const finalComments_pdf = ({ docProps }) => {
]}
>
{values.hasOwnProperty("filesList") &&
values.filesList.map(function (p) {
filterFilesList.map(function (p) {
return (
<View
key={p.name}
+7 -2
View File
@@ -112,8 +112,13 @@ export const other_pdf = ({ docProps }) => {
let values = docProps;
let datestr = values.pinswg_name.split("-");
let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0];
let signedDate = formatDates(new Date()); // datestr[2] + "/" + datestr[1] + "/" + datestr[0];
const isLPA = values.representationCapacity == "lpa" ? true : false;
let filterFilesList = values.hasOwnProperty("filesList")
? values.filesList.filter(function (el) {
return el != null;
})
: [];
return (
<Document>
@@ -293,7 +298,7 @@ export const other_pdf = ({ docProps }) => {
]}
>
{values.hasOwnProperty("filesList") &&
values.filesList.map(function (p) {
filterFilesList.map(function (p) {
return (
<View
key={p.name}
+7 -7
View File
@@ -108,7 +108,7 @@ export const statement_pdf = ({ docProps }) => {
let values = docProps;
let datestr = values.pinswg_name.split("-");
let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0];
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) {
@@ -195,7 +195,7 @@ export const statement_pdf = ({ docProps }) => {
marginBottom: 10,
}}
>
<Text style={styles.questionBullet}>1a.</Text>
<Text style={styles.questionBullet}>2.</Text>
<Text style={styles.questionText}>
{getTrans(
docProps.locale,
@@ -214,7 +214,7 @@ export const statement_pdf = ({ docProps }) => {
marginBottom: 10,
}}
>
<Text style={styles.questionBullet}>1c.</Text>
<Text style={styles.questionBullet}>3.</Text>
<Text style={styles.questionText}>
{getTrans(
docProps.locale,
@@ -243,7 +243,7 @@ export const statement_pdf = ({ docProps }) => {
marginBottom: 10,
}}
>
<Text style={styles.questionBullet}>2.</Text>
<Text style={styles.questionBullet}>4.</Text>
<Text style={styles.questionText}>
{getTrans(
docProps.locale,
@@ -261,7 +261,7 @@ export const statement_pdf = ({ docProps }) => {
marginBottom: 10,
}}
>
<Text style={styles.questionBullet}>3.</Text>
<Text style={styles.questionBullet}>5.</Text>
<Text style={styles.questionText}>
{getTrans(
docProps.locale,
@@ -304,7 +304,7 @@ export const statement_pdf = ({ docProps }) => {
}}
>
<Text style={styles.questionBullet}>
4.
6.
</Text>
<Text style={styles.questionTextMid}>
{getTrans(
@@ -343,7 +343,7 @@ export const statement_pdf = ({ docProps }) => {
marginBottom: 10,
}}
>
<Text style={styles.questionBullet}>5.</Text>
<Text style={styles.questionBullet}>7.</Text>
<Text style={styles.questionText}>
{getTrans(
docProps.locale,
@@ -96,8 +96,13 @@ export const writtenStatement_pdf = ({ docProps }) => {
let values = docProps;
let datestr = values.pinswg_name.split("-");
let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0];
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;
})
: [];
return (
<Document>
@@ -270,7 +275,7 @@ export const writtenStatement_pdf = ({ docProps }) => {
]}
>
{values.hasOwnProperty("filesList") &&
values.filesList.map(function (p) {
filterFilesList.map(function (p) {
return (
<View
key={p.name}
+1
View File
@@ -23,6 +23,7 @@
"footer-terms-conditions-link-label": "Telerau ac amodau",
"footer-terms-conditions-link": "https://llyw.cymru/gwaith-achos-cynllunio-telerau-ac-amodau",
"footer-privacy-link-label": "Preifatrwydd",
"footer-privacy-notice-link-label": "hysbysiad preifatrwydd",
"footer-privacy-link": "https://llyw.cymru/gwaith-achos-cynllunio-hysbysiad-preifatrwydd",
"footer-cookies-link": "Cwcis",
"footer-accessibility-link-label": "Hygyrchedd",
+1 -1
View File
@@ -31,7 +31,7 @@
"rep-check-submit-heading": "Gwiriwch eich sylwadau",
"rep-check-your-rep-heading": "Eich sylwadau",
"rep-check-tandc-para-one": "Mae'r data personol a ddarparwyd gennych ar y ffurflen hon yn cael ei chasglu a'i phrosesu yn unol â thelerau ein cofrestriad o dan Ddeddf Diogelu Data 2018.",
"rep-check-tandc-para-two": "Maer Arolygiaeth Gynllunio yn ystyried ei chyfrifoldebau diogelu data mewn perthynas â'r wybodaeth a roddwch i ni o ddifrif. I gael gwybod mwy am sut rydym yn defnyddio ac yn rheoli eich data personol, ewch i'n hysbysiad preifatrwydd.",
"rep-check-tandc-para-two": "Mae Penderfyniadau Cynllunio ac Amgylchedd Cymru yn cymryd ei chyfrifoldebau diogelu data ar gyfer y wybodaeth a roddwch i ni o ddifrif. I ddarganfod mwy am sut rydym yn defnyddio ac yn rheoli eich data personol, ewch i in hysbysiad preifatrwydd.",
"rep-check-tandc-para-three": "Cadarnhaf fod pob adran or ffurflen hon wediu llenwin llawn a bod y manylion yn gywir hyd eithaf fy ngwybodaeth.",
"rep-check-tandc-para-four": "Cadarnhaf fy mod wedi darllen yr uchod.",
"rep-complete-heading": "Cyflwyno Sylwadau",
+1
View File
@@ -23,6 +23,7 @@
"footer-terms-conditions-link-label": "Terms and conditions",
"footer-terms-conditions-link": "https://gov.wales/planning-casework-terms-and-conditions",
"footer-privacy-link-label": "Privacy",
"footer-privacy-notice-link-label": "privacy notice",
"footer-privacy-link": "https://gov.wales/planning-casework-privacy-notice",
"footer-cookies-link": "Cookies",
"footer-accessibility-link-label": "Accessibility",
+1 -1
View File
@@ -31,7 +31,7 @@
"rep-check-submit-heading": "Check your representation",
"rep-check-your-rep-heading": "Your representation",
"rep-check-tandc-para-one": "The gathering and subsequent processing of the personal data supplied by you in this form, is in accordance with the terms of our registration under the Data Protection Act 2018.",
"rep-check-tandc-para-two": "The Planning Inspectorate takes its data protection responsibilities for the information you provide us with very seriously. To find out more about how we use and manage your personal data, please go to our privacy notice.",
"rep-check-tandc-para-two": "The Planning and Environment Decisions Wales takes its data protection responsibilities for the information you provide us with very seriously. To find out more about how we use and manage your personal data, please go to our",
"rep-check-tandc-para-three": "I confirm that all sections of this form have been fully completed and that the details are correct to the best of my knowledge.",
"rep-check-tandc-para-four": "I confirm I have read the above.",
"rep-complete-heading": "Submission of Representation",
+235
View File
@@ -0,0 +1,235 @@
import { getCsrfToken } from "next-auth/react";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner";
import Footer from "../../components/footer";
import Header from "../../components/header";
import ServiceBanner from "../../components/servicebanner";
import { useRouter } from "next/router";
import { useState, useEffect } from "react";
const SignIn = (props) => {
let { t, lang } = useTranslation();
const router = useRouter();
const { query } = router;
const { footerLinks, pages, csrfToken, callbackUrl } = props;
const [formData, setFormData] = useState({
email: query.email || "",
callbackUrl: "",
csrfToken: "",
});
const [submitForm, setSubmitForm] = useState(false);
const [buttonDisabled, setButtonDisabled] = useState(false);
const [response, setResponse] = useState(null);
const handleInputChange = (e) => {
const { name, value } = e.target;
setFormData((prevState) => ({ ...prevState, [name]: value }));
};
// useEffect(() => {
// // Populate form fields if query params exist
// if (query.email)
// setFormData((prev) => ({ ...prev, email: query.email }));
// if (query.email) {
// handleSubmit(); // Trigger the form submission
// }
// }, [query]);
// const handleSubmit = async () => {
// setButtonDisabled(true); // Disable the submit button to avoid multiple submissions
// // Wait a short moment before programmatically submitting the form
// setTimeout(() => {
// const form = document.getElementById("signin-form"); // Get form by ID
// if (form) {
// form.submit(); // Submit the form
// }
// }, 500); // Short delay to ensure form is populated before submission
// };
const handleSubmit = async (event) => {
event.preventDefault();
setButtonDisabled(true); // Disable the submit button to avoid multiple submissions
try {
const res = await fetch("/api/auth/signin/emailAPI", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData),
});
const data = await res.json();
setResponse(data); // Update response state
} catch (error) {
console.error("Error submitting the form:", error);
}
};
// Trigger form submission automatically when data is ready
useEffect(() => {
// Check if email exists and form data is populated
if (query.email && !response) {
setFormData((prevState) => ({
...prevState,
csrfToken: csrfToken,
callbackUrl: callbackUrl || prevState.callbackUrl, // Ensure callback URL is set
}));
}
}, [query.email, csrfToken, callbackUrl, response]);
useEffect(() => {
// Automatically submit the form when data is ready
if (formData.email && formData.csrfToken && !response) {
handleSubmit(new Event("submit"));
}
}, [formData, response]);
// Handle redirection after form submission based on response
useEffect(() => {
if (response && response.url) {
// Redirect to the URL in the response
router.push(response.url);
}
}, [response, router]);
return (
<div>
<Head>
<title>Sign in</title>
</Head>
<div id="page_wrapper">
<CookieBanner />
<Header />
<div className="govuk-width-container govuk-!-padding-bottom-9">
<Breadcrumbs />
<ServiceBanner noSignin={true} />
<main
className="govuk-main-wrapper govuk-main-wrapper--auto-spacing "
id="signin"
role="main"
>
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
<div className="card">
<div className="card-body">
<div className="govuk-body-m">
<legend className="govuk-fieldset__legend govuk-fieldset__legend--l">
<h1 className="govuk-fieldset__heading govuk-heading-m">
Sign in
</h1>
</legend>
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds ">
<form
id="signin-form"
method="post"
action="/api/auth/signin/emailAPI"
onSubmit={handleSubmit}
>
<div
className={
"govuk-form-group "
}
>
<input
className="govuk-input"
name="csrfToken"
type="hidden"
defaultValue={
csrfToken
}
onChange={
handleInputChange
}
/>
<input
className="govuk-input"
name="callbackUrl"
type="hidden"
onChange={
handleInputChange
}
/>
<label
className="govuk-label"
htmlFor="email"
>
Email address
</label>
<input
className="govuk-input govuk-!-width-three-quarters"
type="email"
id="email"
name="email"
value={
formData.email
}
onChange={
handleInputChange
}
/>
</div>
<div className="govuk-form-group">
<button
type="submit"
className="govuk-button"
disabled={
buttonDisabled
}
>
Submit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<Footer footerLinks={footerLinks} ticketnumber={props} />
</div>
</div>
);
};
export async function getServerSideProps(context) {
if (process.env.SHOWLOGIN == false) {
return {
redirect: {
destination: "/404",
permanent: false,
},
};
}
const csrfToken = await getCsrfToken(context);
console.log(
"\n//////////////////////\n",
"Sign in callbackurl: " + context.query.callbackUrl,
context.locale,
csrfToken + "\n//////////////////////\n"
);
let formURL = context.query.callbackUrl;
//console.log("formUrl:", formURL);
formURL = typeof formURL == "undefined" ? null : formURL;
return {
props: { csrfToken: csrfToken, callbackUrl: formURL },
};
}
export default SignIn;