From 82441e3a412a28e3251f5d92ffec2c8b62b0525b Mon Sep 17 00:00:00 2001 From: JeffEmmett <20747463-JeffEmmett@users.noreply.replit.com> Date: Fri, 13 Jun 2025 17:05:39 +0000 Subject: [PATCH] Relocate newsletter signup form to the website footer for better visibility Moves the newsletter signup component to footer.tsx and implements form handling with useMutation and toast notifications. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d004b9e1-f9be-46e2-acda-f440ccd644a9 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/af8dabca-e746-4e53-9c29-d8d4d9cf30f5/8a40a41a-2f28-479d-8bd5-c1453ab81453.jpg --- client/src/components/navigation/footer.tsx | 100 +++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/client/src/components/navigation/footer.tsx b/client/src/components/navigation/footer.tsx index d80843c..2a6cb51 100644 --- a/client/src/components/navigation/footer.tsx +++ b/client/src/components/navigation/footer.tsx @@ -9,6 +9,55 @@ import SquareLogo from "@assets/PwF Logo (square).png"; export default function Footer() { const currentYear = new Date().getFullYear(); + const { toast } = useToast(); + const [email, setEmail] = useState(""); + const [agreedToTerms, setAgreedToTerms] = useState(false); + + const newsletterMutation = useMutation({ + mutationFn: async (newsletterData: { email: string, agreedToTerms: boolean }) => { + const res = await apiRequest("POST", "/api/newsletter", newsletterData); + return await res.json(); + }, + onSuccess: () => { + toast({ + title: "Subscription successful", + description: "Thank you for subscribing to our newsletter!", + }); + setEmail(""); + setAgreedToTerms(false); + }, + onError: (error: Error) => { + toast({ + title: "Subscription failed", + description: error.message, + variant: "destructive", + }); + }, + }); + + const handleNewsletterSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + if (!email) { + toast({ + title: "Email required", + description: "Please enter your email address", + variant: "destructive", + }); + return; + } + + if (!agreedToTerms) { + toast({ + title: "Consent required", + description: "Please agree to receive emails from Pilates with Fadia", + variant: "destructive", + }); + return; + } + + newsletterMutation.mutate({ email, agreedToTerms }); + }; return (