Contact integration updated
This commit is contained in:
parent
48bc106e24
commit
6a6d064754
@ -21,18 +21,15 @@ export default function ContactClient() {
|
|||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
// console.log("Input Changed:", name, value);
|
|
||||||
setFormData((prev) => ({ ...prev, [name]: value }));
|
setFormData((prev) => ({ ...prev, [name]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCaptchaChange = (token) => {
|
const handleCaptchaChange = (token) => {
|
||||||
// console.log("Captcha Token:", token);
|
|
||||||
setCaptchaToken(token);
|
setCaptchaToken(token);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// console.log("Form Submitted:", formData);
|
|
||||||
|
|
||||||
const errors = {};
|
const errors = {};
|
||||||
if (!formData.username.trim()) errors.username = "Name is required.";
|
if (!formData.username.trim()) errors.username = "Name is required.";
|
||||||
@ -43,11 +40,13 @@ export default function ContactClient() {
|
|||||||
if (!captchaToken) errors.captcha = "Please verify the CAPTCHA.";
|
if (!captchaToken) errors.captcha = "Please verify the CAPTCHA.";
|
||||||
|
|
||||||
setFormErrors(errors);
|
setFormErrors(errors);
|
||||||
// console.log("Form Errors:", errors);
|
|
||||||
if (Object.keys(errors).length > 0) return;
|
if (Object.keys(errors).length > 0) return;
|
||||||
|
|
||||||
const emailData = {
|
const emailData = {
|
||||||
...formData,
|
name: formData.username,
|
||||||
|
phone: formData.phone,
|
||||||
|
email: formData.email,
|
||||||
|
subject: formData.service,
|
||||||
message: `Service: ${formData.service}<br /><br />Message: ${formData.message}`,
|
message: `Service: ${formData.service}<br /><br />Message: ${formData.message}`,
|
||||||
to: "bloor@rapharehab.ca",
|
to: "bloor@rapharehab.ca",
|
||||||
senderName: "Rapha Rehab Contact Page",
|
senderName: "Rapha Rehab Contact Page",
|
||||||
@ -55,11 +54,11 @@ export default function ContactClient() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// console.log("Sending email:", emailData);
|
const res = await axios.post(
|
||||||
const res = await axios.post("/api/sendMail", emailData, {
|
"https://mailserver.metatronnest.com/send",
|
||||||
headers: { "Content-Type": "application/json" },
|
emailData,
|
||||||
});
|
{ headers: { "Content-Type": "application/json" } }
|
||||||
// console.log("Email Response:", res.data);
|
);
|
||||||
|
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
@ -67,17 +66,10 @@ export default function ContactClient() {
|
|||||||
message: res?.data?.message || "Message sent successfully!",
|
message: res?.data?.message || "Message sent successfully!",
|
||||||
});
|
});
|
||||||
|
|
||||||
setFormData({
|
setFormData({ username: "", email: "", phone: "", service: "", message: "" });
|
||||||
username: "",
|
|
||||||
email: "",
|
|
||||||
phone: "",
|
|
||||||
service: "",
|
|
||||||
message: "",
|
|
||||||
});
|
|
||||||
setCaptchaToken(null);
|
setCaptchaToken(null);
|
||||||
setFormErrors({});
|
setFormErrors({});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.error("❌ Error sending email:", error);
|
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
type: "danger",
|
type: "danger",
|
||||||
|
|||||||
@ -3026,6 +3026,7 @@
|
|||||||
|
|
||||||
.default-form .form-group input[type='text'],
|
.default-form .form-group input[type='text'],
|
||||||
.default-form .form-group input[type='email'],
|
.default-form .form-group input[type='email'],
|
||||||
|
.form-control,
|
||||||
.default-form .form-group textarea {
|
.default-form .form-group textarea {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user