From 16f59adc17f551356e76a9a9b31339f406857705 Mon Sep 17 00:00:00 2001 From: akash Date: Fri, 17 Oct 2025 14:01:20 +0530 Subject: [PATCH] Responsive & new no index appointment booking form updated --- app/appointment-booking-form/ContactClient.js | 254 ++++++++++++++++++ app/appointment-booking-form/page.js | 27 ++ app/covid-19-updates/CovidClient.js | 2 +- .../WhyusClient.js | 10 +- public/assets/css/module-css/solutions.css | 8 + public/assets/css/style.css | 5 + 6 files changed, 300 insertions(+), 6 deletions(-) create mode 100644 app/appointment-booking-form/ContactClient.js create mode 100644 app/appointment-booking-form/page.js diff --git a/app/appointment-booking-form/ContactClient.js b/app/appointment-booking-form/ContactClient.js new file mode 100644 index 0000000..63bad89 --- /dev/null +++ b/app/appointment-booking-form/ContactClient.js @@ -0,0 +1,254 @@ +"use client"; + +import { useState, useEffect } from "react"; +import ReCAPTCHA from "react-google-recaptcha"; +import axios from "axios"; +import Link from "next/link"; +import { servicesList } from "@/utils/Services.utils"; + +export default function ContactClient() { + const [formData, setFormData] = useState({ + username: "", + email: "", + phone: "", + service: "", + message: "", + }); + + const [formErrors, setFormErrors] = useState({}); + const [captchaToken, setCaptchaToken] = useState(null); + const [alert, setAlert] = useState({ show: false, type: "", message: "" }); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData((prev) => ({ ...prev, [name]: value })); + }; + + const handleCaptchaChange = (token) => { + setCaptchaToken(token); + }; + + const handleSubmit = async (e) => { + e.preventDefault(); + + const errors = {}; + if (!formData.username.trim()) errors.username = "Name is required."; + if (!formData.email.trim()) errors.email = "Email is required."; + if (!formData.phone.trim()) errors.phone = "Phone is required."; + if (!formData.service.trim()) errors.service = "Please select a service."; + if (!formData.message.trim()) errors.message = "Message is required."; + // if (!captchaToken) errors.captcha = "Please verify the CAPTCHA."; + + setFormErrors(errors); + if (Object.keys(errors).length > 0) return; + + const emailData = { + name: formData.username, + phone: formData.phone, + email: formData.email, + subject: formData.service, + message: `Service: ${formData.service}

Message: ${formData.message}`, + to: "bloor@rapharehab.ca", + senderName: "Rapha Rehab Contact Page", + recaptchaToken: captchaToken, + }; + + try { + const res = await axios.post( + "https://mailserver.metatronnest.com/send", + emailData, + { headers: { "Content-Type": "application/json" } } + ); + + setAlert({ + show: true, + type: "success", + message: res?.data?.message || "Message sent successfully!", + }); + + setFormData({ username: "", email: "", phone: "", service: "", message: "" }); + setCaptchaToken(null); + setFormErrors({}); + } catch (error) { + setAlert({ + show: true, + type: "danger", + message: "Failed to send message. Please try again later.", + }); + } + }; + + + useEffect(() => { + if (alert.show) { + const timer = setTimeout(() => { + setAlert((prev) => ({ ...prev, show: false })); + }, 5000); + return () => clearTimeout(timer); + } + }, [alert.show]); + + return ( +
+ {/*
+
+
+
+
+

Quick Contact

+
+
+

+ +647-722-3434
+ +416-622-2873 +

+
+
+
+
+
+

Email Address

+
+
+

+ bloor@rapharehab.ca +

+
+
+
+
+
+

Mailing Address

+
+
+ +
+

5 – 4335 Bloor Street West
Etobicoke, M9C 2A5

+
+
+
+
+
+
*/} + +
+
+
+
+
+
+

How can we help?

+

+ Please complete the contact information below and let us know your needs. + Upon receipt of your information one of our team members will reach out. +

+
+ + {alert.show && ( +
{alert.message}
+ )} + +
+
+
+ + {formErrors.username && {formErrors.username}} +
+ +
+ + {formErrors.phone && {formErrors.phone}} +
+ +
+ + {formErrors.email && {formErrors.email}} +
+ +
+ + {formErrors.service && {formErrors.service}} +
+ +
+ + {formErrors.message && {formErrors.message}} +
+ +
+ + {formErrors.captcha && {formErrors.captcha}} +
+ +
+ +
+
+
+
+
+ +
+
+ Physiotherapy at Rapharehab +
+
+
+
+
+ + {/*
+
+