File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ export default function NewsletterSubscribe({
51
51
const [ email , setEmail ] = useState < string > ( '' ) ;
52
52
const [ name , setName ] = useState < string > ( '' ) ;
53
53
const [ status , setStatus ] = useState < FormStatus > ( FormStatus . NORMAL ) ;
54
- const [ emailError , setEmailError ] = useState < string > ( '' ) ;
54
+ const [ emailError , setEmailError ] = useState < ( error : string ) => void > ( ) ;
55
+
55
56
const { t, ready } = useTranslation ( 'common' , { keyPrefix : 'newsletterCTA' } ) ;
56
57
57
58
const headTextColor = dark ? 'text-white' : '' ;
@@ -71,10 +72,12 @@ export default function NewsletterSubscribe({
71
72
//validate email
72
73
const emailPattern = / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / ;
73
74
if ( ! emailPattern . test ( email ) ) {
75
+ setEmailError ( 'Invalid email address' ) ;
74
76
setFormStatus ( FormStatus . ERROR ) ;
75
77
return ;
76
78
}
77
79
setEmailError ( '' ) ; // Clear error if valid
80
+ setStatus ( FormStatus . LOADING ) ;
78
81
//end
79
82
const data = {
80
83
name,
You can’t perform that action at this time.
0 commit comments