@@ -14,17 +14,38 @@ import {
1414 FaYoutube ,
1515} from "react-icons/fa6" ;
1616import { Mail } from "lucide-react" ;
17-
17+ import toast from "react-hot-toast" ;
1818export default function Footer ( ) {
1919 const { theme } = useTheme ( ) ;
2020 const [ isDarkMode , setIsDarkMode ] = useState < boolean | null > ( true ) ;
21-
21+ const [ email , setEmail ] = useState ( "" ) ;
2222 useEffect ( ( ) => {
2323 if ( theme ) {
2424 setIsDarkMode ( theme === "dark" ) ;
2525 }
2626 } , [ theme ] ) ;
27-
27+ const handleSubscribe = async ( ) => {
28+ if ( ! email || ! email . includes ( "@" ) ) {
29+ toast . error ( "Please Enter A Valid Email." ) ;
30+ return ;
31+ }
32+
33+ const fakeSubscribe = ( ) =>
34+ new Promise ( ( resolve , reject ) => {
35+ setTimeout ( ( ) => {
36+ resolve ( "Subscribed" ) ;
37+ } , 1500 ) ;
38+ } ) ;
39+
40+ toast . promise ( fakeSubscribe ( ) , {
41+ loading : "Subscribing..." ,
42+ success : "You've Successfully Subscribed!" ,
43+ error : "Something Went Wrong. Please Try Again." ,
44+ } ) ;
45+
46+ setEmail ( "" ) ;
47+ } ;
48+
2849 return (
2950 < footer className = "w-full overflow-hidden bg-gradient-to-b from-[#F3F5FF] to-[#A599CE] px-12 py-12 font-sans text-white dark:from-[#070114] dark:to-[#1F0234]" >
3051 < div className = "mx-auto flex max-w-[1440px] flex-col gap-y-4 lg:flex-row lg:justify-between" >
@@ -107,8 +128,11 @@ export default function Footer() {
107128 type = "email"
108129 placeholder = "Enter Your Email"
109130 className = "pr-24"
131+ value = { email }
132+ onChange = { ( e ) => setEmail ( e . target . value ) }
110133 />
111134 < Button
135+ onClick = { handleSubscribe }
112136 className = "absolute right-0 top-0 h-full rounded-l-none rounded-r-md bg-[#562EE7] px-4 text-white hover:bg-[#4531b3]"
113137 >
114138 Subscribe!
0 commit comments