diff --git a/frontend/src/Components/common/Footer/Footer.jsx b/frontend/src/Components/common/Footer/Footer.jsx index 464b792..eff514b 100644 --- a/frontend/src/Components/common/Footer/Footer.jsx +++ b/frontend/src/Components/common/Footer/Footer.jsx @@ -1,13 +1,49 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Link } from 'react-router-dom'; const Footer = () => { + const [email, setEmail] = useState(''); + const [emailError, setEmailError] = useState(''); + const [isSubscribed, setIsSubscribed] = useState(false); + const scrollToTop = () => { window.scrollTo({ top: 0, behavior: 'smooth', }); }; + const validateEmail = (email) => { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(email); + }; + const handleEmailChange = (e) => { + const value = e.target.value; + setEmail(value); + if (emailError) { + setEmailError(''); + } + }; + const handleSubscribe = (e) => { + e.preventDefault(); + setEmailError(''); + setIsSubscribed(false); + if (!email.trim()) { + setEmailError('Please enter your email address'); + return; + } + if (!validateEmail(email)) { + setEmailError('Please enter a valid email address'); + return; + } + setIsSubscribed(true); + setEmail(''); + console.log('Subscribing email:', email); + + + setTimeout(() => { + setIsSubscribed(false); + }, 3000); + }; return (
@@ -34,17 +70,35 @@ const Footer = () => { Get the latest news, articles and resources directly in your Inbox weekly
-
- - - - -
+ + {emailError && ( +
+ {emailError} +
+ )} + {isSubscribed && ( +
+ Thank you for subscribing! You'll receive our newsletter soon. +
+ )} +