@@ -14,17 +14,38 @@ import {
14
14
FaYoutube ,
15
15
} from "react-icons/fa6" ;
16
16
import { Mail } from "lucide-react" ;
17
-
17
+ import toast from "react-hot-toast" ;
18
18
export default function Footer ( ) {
19
19
const { theme } = useTheme ( ) ;
20
20
const [ isDarkMode , setIsDarkMode ] = useState < boolean | null > ( true ) ;
21
-
21
+ const [ email , setEmail ] = useState ( "" ) ;
22
22
useEffect ( ( ) => {
23
23
if ( theme ) {
24
24
setIsDarkMode ( theme === "dark" ) ;
25
25
}
26
26
} , [ 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
+
28
49
return (
29
50
< 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]" >
30
51
< 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() {
107
128
type = "email"
108
129
placeholder = "Enter Your Email"
109
130
className = "pr-24"
131
+ value = { email }
132
+ onChange = { ( e ) => setEmail ( e . target . value ) }
110
133
/>
111
134
< Button
135
+ onClick = { handleSubscribe }
112
136
className = "absolute right-0 top-0 h-full rounded-l-none rounded-r-md bg-[#562EE7] px-4 text-white hover:bg-[#4531b3]"
113
137
>
114
138
Subscribe!
0 commit comments