File tree Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -51,29 +51,23 @@ const ContactForm = () => {
51
51
setInputs ( { ...inputs , [ e . target . name ] : e . target . value } ) ;
52
52
} ;
53
53
54
- const handelSubmit = ( e : FormEvent < HTMLFormElement > ) => {
54
+ const handelSubmit = async ( e : FormEvent < HTMLFormElement > ) => {
55
55
e . preventDefault ( ) ;
56
56
if ( errors . length > 0 ) return ;
57
57
dispatch ( setFormData ( inputs ) ) ;
58
58
dispatch ( setFormStatus ( 'loading' ) ) ;
59
59
if ( formEl . current == null ) throw new Error ( ) ;
60
60
61
- emailjs
62
- . sendForm (
63
- import . meta. env . VITE_EMAILJS_SERVICE_ID ,
64
- import . meta. env . VITE_EMAILJS_TEMPLATE_ID ,
65
- formEl . current ,
66
- import . meta. env . VITE_EMAILJS_PUBLIC_KEY ,
67
- )
68
- . then (
69
- ( ) => {
70
- setInputs ( initialState ) ;
71
- dispatch ( setFormStatus ( 'completed' ) ) ;
72
- } ,
73
- ( ) => {
74
- dispatch ( setFormStatus ( 'rejected' ) ) ;
75
- } ,
76
- ) ;
61
+ const res = await emailjs . sendForm (
62
+ 'service_qdjdol9' ,
63
+ 'template_lobv7nq' ,
64
+ formEl . current ,
65
+ 'G0MWsjYi9pbxnAwfJ' ,
66
+ ) ;
67
+ if ( res . status === 200 ) {
68
+ return dispatch ( setFormStatus ( 'completed' ) ) ;
69
+ }
70
+ return dispatch ( setFormStatus ( 'rejected' ) ) ;
77
71
} ;
78
72
79
73
return (
You can’t perform that action at this time.
0 commit comments