diff --git a/frontend/src/components/Layout/Footer.tsx b/frontend/src/components/Layout/Footer.tsx index 8256ea4..5669add 100644 --- a/frontend/src/components/Layout/Footer.tsx +++ b/frontend/src/components/Layout/Footer.tsx @@ -1,15 +1,42 @@ +import { useState } from "react"; import { Mail, Facebook, Twitter, Instagram, Linkedin } from "lucide-react"; const Footer = () => { + const [email, setEmail] = useState(""); + + const handleKeyDown = async (event) => { + if (event.key === "Enter") { + if (email.trim() === "") return; + try { + const response = await fetch(`/api/send_newsletter/${email}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }); + + if (!response.ok) { + throw new Error("Failed to subscribe"); + } + + setEmail(""); + alert("Successfully added to newsletter"); + + } catch (error) { + console.error("Error subscribing:", error); + } + + } + }; + return (