16493 routing for PET team send email

This commit is contained in:
2025-05-28 14:12:31 +01:00
parent e04f87323f
commit 8e6b88984f
2 changed files with 37 additions and 67 deletions
+31 -2
View File
@@ -7,7 +7,6 @@ import Footer from "../components/footer";
import Header from "../components/header";
import ServiceBanner from "../components/servicebanner";
import Link from "next/link";
import { PickList } from "../components/elements";
import {
Field,
change,
@@ -296,6 +295,8 @@ let ContactUs = (props) => {
// Only called if validation passes
sendContactEmail(formValues);
createCRMTask(formValues);
formValues.typeOfContact == "plq" &&
sendPETEmail(formValues, props.petEmail);
console.log("Form submitted:", formValues);
};
@@ -329,6 +330,33 @@ let ContactUs = (props) => {
}
};
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 (
<div>
<Head>
@@ -339,7 +367,7 @@ let ContactUs = (props) => {
<Header />
<div className="govuk-width-container">
<Breadcrumbs />
<ServiceBanner />
<ServiceBanner props={props} />
<main
className="govuk-main-wrapper govuk-!-padding-top-9 govuk-main-wrapper--auto-spacing"
id="main-content"
@@ -468,6 +496,7 @@ const mapStateToProps = (state) => {
return {
typeOfContactValue,
initialValues: email ? { contactEmail: email } : {},
petEmail: process.env.NEXT_PUBLIC_PETEMAIL,
};
};