1
1
"use client" ;
2
2
// @flow strict
3
- import { isValidEmail } from ' @/utils/check-email' ;
4
- import axios from ' axios' ;
5
- import { useState } from ' react' ;
3
+ import { isValidEmail } from " @/utils/check-email" ;
4
+ import axios from " axios" ;
5
+ import { useState } from " react" ;
6
6
import { TbMailForward } from "react-icons/tb" ;
7
- import { toast } from 'react-toastify' ;
7
+ import { toast } from "react-toastify" ;
8
+ import emailjs from "@emailjs/browser" ;
8
9
9
10
function ContactWithoutCaptcha ( ) {
10
11
const [ error , setError ] = useState ( { email : false , required : false } ) ;
11
12
const [ userInput , setUserInput ] = useState ( {
12
- name : '' ,
13
- email : '' ,
14
- message : '' ,
13
+ name : "" ,
14
+ email : "" ,
15
+ message : "" ,
15
16
} ) ;
16
17
17
18
const checkRequired = ( ) => {
@@ -29,7 +30,7 @@ function ContactWithoutCaptcha() {
29
30
return ;
30
31
} else {
31
32
setError ( { ...error , required : false } ) ;
32
- } ;
33
+ }
33
34
34
35
const serviceID = process . env . NEXT_PUBLIC_EMAILJS_SERVICE_ID ;
35
36
const templateID = process . env . NEXT_PUBLIC_EMAILJS_TEMPLATE_ID ;
@@ -38,29 +39,24 @@ function ContactWithoutCaptcha() {
38
39
try {
39
40
const res = await emailjs . send ( serviceID , templateID , userInput , options ) ;
40
41
const teleRes = await axios . post ( `${ process . env . NEXT_PUBLIC_APP_URL } /api/contact` , userInput ) ;
41
-
42
42
if ( res . status === 200 || teleRes . status === 200 ) {
43
- toast . success ( ' Message sent successfully!' ) ;
43
+ toast . success ( " Message sent successfully!" ) ;
44
44
setUserInput ( {
45
- name : '' ,
46
- email : '' ,
47
- message : '' ,
45
+ name : "" ,
46
+ email : "" ,
47
+ message : "" ,
48
48
} ) ;
49
- } ;
49
+ }
50
50
} catch ( error ) {
51
51
toast . error ( error ?. text || error ) ;
52
- } ;
52
+ }
53
53
} ;
54
54
55
55
return (
56
56
< div className = "" >
57
- < p className = "font-medium mb-5 text-[#16f2b3] text-xl uppercase" >
58
- Contact with me
59
- </ p >
57
+ < p className = "font-medium mb-5 text-[#16f2b3] text-xl uppercase" > Contact with me</ p >
60
58
< div className = "max-w-3xl text-white rounded-lg border border-[#464c6a] p-3 lg:p-5" >
61
- < p className = "text-sm text-[#d3d8e8]" >
62
- { "If you have any questions or concerns, please don't hesitate to contact me. I am open to any work opportunities that align with my skills and interests." }
63
- </ p >
59
+ < p className = "text-sm text-[#d3d8e8]" > { "If you have any questions or concerns, please don't hesitate to contact me. I am open to any work opportunities that align with my skills and interests." } </ p >
64
60
< div className = "mt-6 flex flex-col gap-4" >
65
61
< div className = "flex flex-col gap-2" >
66
62
< label className = "text-base" > Your Name: </ label >
@@ -89,9 +85,7 @@ function ContactWithoutCaptcha() {
89
85
setError ( { ...error , email : ! isValidEmail ( userInput . email ) } ) ;
90
86
} }
91
87
/>
92
- { error . email &&
93
- < p className = "text-sm text-red-400" > Please provide a valid email!</ p >
94
- }
88
+ { error . email && < p className = "text-sm text-red-400" > Please provide a valid email!</ p > }
95
89
</ div >
96
90
97
91
< div className = "flex flex-col gap-2" >
@@ -108,11 +102,7 @@ function ContactWithoutCaptcha() {
108
102
/>
109
103
</ div >
110
104
< div className = "flex flex-col items-center gap-2" >
111
- { error . required &&
112
- < p className = "text-sm text-red-400" >
113
- Email and Message are required!
114
- </ p >
115
- }
105
+ { error . required && < p className = "text-sm text-red-400" > Email and Message are required!</ p > }
116
106
< button
117
107
className = "flex items-center gap-1 hover:gap-3 rounded-full bg-gradient-to-r from-pink-500 to-violet-600 px-5 md:px-12 py-2.5 md:py-3 text-center text-xs md:text-sm font-medium uppercase tracking-wider text-white no-underline transition-all duration-200 ease-out hover:text-white hover:no-underline md:font-semibold"
118
108
role = "button"
@@ -126,6 +116,6 @@ function ContactWithoutCaptcha() {
126
116
</ div >
127
117
</ div >
128
118
) ;
129
- } ;
119
+ }
130
120
131
- export default ContactWithoutCaptcha ;
121
+ export default ContactWithoutCaptcha ;
0 commit comments