- {/* Extra icons */}
- {extraIcons.map((icon, i) => (
-
-
-
- ))}
+ <>
+ {/* Floating Contact Buttons */}
+
+ {open && (
+
+ {extraIcons.map((icon, i) =>
+ icon.href ? (
+
+
+
+ ) : (
+
+ )
+ )}
+
+ )}
- {/* Main floating button */}
-
+
+
+
+ {/* Chat Form Sidebar */}
+ {showChat && (
+
setShowChat(false)} />
+ )}
+ >
+ );
+}
+
+/** Contact Form Sidebar */
+function ChatForm({ onClose }) {
+ const [formData, setFormData] = useState({
+ username: "",
+ lname: "",
+ email: "",
+ phone: "",
+ subject: "",
+ 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 = "First Name is required.";
+ if (!formData.lname.trim()) errors.lname = "Last Name is required.";
+ if (!formData.email.trim()) errors.email = "Email is required.";
+ if (!formData.phone.trim()) errors.phone = "Phone is required.";
+ if (!formData.subject.trim()) errors.subject = "Subject is required.";
+ 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 = {
+ ...formData,
+ message: `Subject: ${formData.subject}
Message: ${formData.message}`,
+ to: "bloor@rapharehab.ca",
+ senderName: "Rapha Rehab Chat Form",
+ 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: "",
+ lname: "",
+ email: "",
+ phone: "",
+ subject: "",
+ message: "",
+ });
+ setCaptchaToken(null);
+ setFormErrors({});
+ } catch (error) {
+ setAlert({
+ show: true,
+ type: "danger",
+ message: "Failed to send message. Please try again later.",
+ });
+ }
+ };
+
+ return (
+
+
+
Chat with Us
+
+
+
+
+ {alert.show && (
+
{alert.message}
+ )}
+
+
+
);
}
diff --git a/components/SocialFloat.js b/components/SocialFloat.js
new file mode 100644
index 0000000..c47e11e
--- /dev/null
+++ b/components/SocialFloat.js
@@ -0,0 +1,99 @@
+"use client";
+import React, { useState } from "react";
+
+export default function SocialFloat() {
+ const [open, setOpen] = useState(false);
+
+ /** Social icons */
+ const socialIcons = [
+ {
+ href: "https://www.facebook.com/ELRaphaRehabCenter/",
+ iconClass: "icon-4", // Facebook
+ label: "Facebook",
+ offset: -40,
+ },
+ {
+ href: "https://www.instagram.com/elrapharehab/",
+ iconClass: "icon-7", // Instagram
+ label: "Instagram",
+ offset: 40,
+ },
+ ];
+
+ return (
+
+ {/* Extra social icons */}
+ {open && (
+
+ {socialIcons.map((icon, i) => (
+
+
+
+ ))}
+
+ )}
+
+ {/* Main floating button */}
+
+
+ );
+}
diff --git a/components/layout/Layout.js b/components/layout/Layout.js
index 3fc69d4..48abe61 100644
--- a/components/layout/Layout.js
+++ b/components/layout/Layout.js
@@ -18,6 +18,7 @@ import Header2 from './header/Header2';
import Header3 from "./header/Header3";
import Header4 from "./header/Header4";
import ContactFloat from "../ContactFloat";
+import SocialFloat from "../SocialFloat";
export default function Layout({ headerStyle, footerStyle, headTitle, breadcrumbTitle, bannerImage, children, wrapperCls }) {
const [scroll, setScroll] = useState(0);
@@ -68,6 +69,7 @@ export default function Layout({ headerStyle, footerStyle, headTitle, breadcrumb
{footerStyle === 2 && }