+ Questions about Planning legislation or policy +
+ ); + break; + case "ipq": + contactPurposeBody = ( ++ Questions or comments about applications for major + infrastructure projects +
+ ); + break; + case "pcpq": + contactPurposeBody = ( ++ Questions or comments about planning and environmental + appeals +
+ ); + break; + case "pi": + contactPurposeBody = ( ++ Query about using the Casework Portal +
+ ); + break; + case "appadvice": + contactPurposeBody = ( +Advice How to submit an appeal
+ ); + break; + case "repadvice": + contactPurposeBody = ( ++ Advice How to comment on an appeal or application +
+ ); + break; + case "ceq": + contactPurposeBody = ( ++ Queries about forthcoming Hearing or Inquiry event +
+ ); + break; + case "other": + contactPurposeBody = ( +Other enquiry for PEDW
+ ); + break; + case "postdec": + contactPurposeBody = ( ++ Issues or questions about a case after the decision is + issued +
+ ); + break; + case "comp": + contactPurposeBody = ( +General Complaints of Compliments
+ ); + break; + default: + // code block + } + + return contactPurposeBody; +}; + +let t; + +let ContactUs = (props) => { + const { footerLinks, pages } = props; + let { t } = useTranslation(); + + const [formSubmitted, setFormSubmitted] = useState(false); + + const router = useRouter(); + const { locale } = router; + + const required = (value) => + value ? undefined : t("newappeal:is-required-label"); + + const emailRegex = + /^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(?:\[(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:.+)])$/; + + const email = (value) => + value && !emailRegex.test(value) + ? t("account:invalid-email-address-errormsg") + : undefined; + + const onSubmit = async (formValues) => { + // Only called if validation passes + sendContactEmail(formValues); + createCRMTask(formValues); + formValues.typeOfContact == "plq" && + sendPETEmail(formValues, props.petEmail); + console.log("Form submitted:", formValues); + }; + + const sendContactEmail = async (formValues) => { + Object.assign(formValues, { + "contactSubject": contactPurpose(formValues.typeOfContact).props + .children, + }); + + const reference = "PEDW-CONTACT-US"; + const templateId = "69228c5f-8500-40ff-a6c5-95a9434c3ec8"; + const templateIdCY = "b8f1f76d-4ab9-4a2f-b294-e3623c6095a3"; + + try { + const res = await sendEmail( + router.locale !== "en" ? templateIdCY : templateId, + formValues.contactEmail, + formValues, + reference + ); + + console.log("Email sent successfully."); + setFormSubmitted(true); + } catch (error) { + console.error("Email sending failed:", error); + alert("Something went wrong. Please try again later."); + // Required: inform redux-form this is a submit error + throw new SubmissionError({ + _error: "Failed to send email. Please try again later.", + }); + } + }; + + const sendPETEmail = async (formValues, petEmail) => { + const reference = "PEDW-CONTACT-US-PET"; + const templateId = "56bbdcf9-d63d-48e9-a794-3e253dd7498b"; + const templateIdCY = "00b794d3-29aa-434d-b696-0ef0b0337d79"; + + console.log(petEmail); + + try { + const res = await sendEmail( + templateId, + petEmail, + formValues, + reference + ); + + console.log("Email sent successfully."); + setFormSubmitted(true); + } catch (error) { + console.error("Email sending failed:", error); + alert("Something went wrong. Please try again later."); + // Required: inform redux-form this is a submit error + throw new SubmissionError({ + _error: "Failed to send email. Please try again later.", + }); + } + }; + + return ( ++ Contact us{" "} +
+ ++ Thank you for your enquiry +
++ Lorem ipsum dolor sit amet, + consectetur adipiscing elit. + Nulla congue leo ac quam + pulvinar, id vulputate libero + volutpat. Maecenas ut odio id + nisl laoreet dictum. Nam + faucibus, leo vitae egestas + lacinia, enim tortor bibendum + lorem, ut tincidunt lacus sapien + quis lorem. Aenean interdum + dolor augue, ac cursus lectus + suscipit vitae.{" "} +
+ + > + )} +