Contact integration updated

This commit is contained in:
akash 2025-10-08 20:54:07 +05:30
parent 48bc106e24
commit 6a6d064754
2 changed files with 11 additions and 18 deletions

View File

@ -21,18 +21,15 @@ export default function ContactClient() {
const handleChange = (e) => {
const { name, value } = e.target;
// console.log("Input Changed:", name, value);
setFormData((prev) => ({ ...prev, [name]: value }));
};
const handleCaptchaChange = (token) => {
// console.log("Captcha Token:", token);
setCaptchaToken(token);
};
const handleSubmit = async (e) => {
e.preventDefault();
// console.log("Form Submitted:", formData);
const errors = {};
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.";
setFormErrors(errors);
// console.log("Form Errors:", errors);
if (Object.keys(errors).length > 0) return;
const emailData = {
...formData,
name: formData.username,
phone: formData.phone,
email: formData.email,
subject: formData.service,
message: `Service: ${formData.service}<br /><br />Message: ${formData.message}`,
to: "bloor@rapharehab.ca",
senderName: "Rapha Rehab Contact Page",
@ -55,11 +54,11 @@ export default function ContactClient() {
};
try {
// console.log("Sending email:", emailData);
const res = await axios.post("/api/sendMail", emailData, {
headers: { "Content-Type": "application/json" },
});
// console.log("Email Response:", res.data);
const res = await axios.post(
"https://mailserver.metatronnest.com/send",
emailData,
{ headers: { "Content-Type": "application/json" } }
);
setAlert({
show: true,
@ -67,17 +66,10 @@ export default function ContactClient() {
message: res?.data?.message || "Message sent successfully!",
});
setFormData({
username: "",
email: "",
phone: "",
service: "",
message: "",
});
setFormData({ username: "", email: "", phone: "", service: "", message: "" });
setCaptchaToken(null);
setFormErrors({});
} catch (error) {
// console.error("❌ Error sending email:", error);
setAlert({
show: true,
type: "danger",

View File

@ -3026,6 +3026,7 @@
.default-form .form-group input[type='text'],
.default-form .form-group input[type='email'],
.form-control,
.default-form .form-group textarea {
position: relative;
display: block;