File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -19,17 +19,27 @@ let resetMessage = () => {
19
19
document . getElementById ( "empty-error-message" ) . hidden = true ;
20
20
} ;
21
21
22
+ let isNewEmail = ( email ) => {
23
+ return usersTable . filter ( ( user ) => user . username === email ) . length === 0 ;
24
+ } ;
25
+
26
+ let isEmptyEmail = ( email ) => {
27
+ return email . length === 0 ;
28
+ } ;
29
+
22
30
addEventListener ( "submit" , ( event ) => {
23
31
event . preventDefault ( ) ;
24
32
resetMessage ( ) ;
25
33
26
34
let email = document . getElementById ( "email" ) . value ;
27
35
28
- // TODO: Show Correct Status Messages on Signup Form
29
- // 1. successful signup
30
- // 2. empty email
31
- // 3. taken email
32
- // 4. repeat email
36
+ if ( isEmptyEmail ( email ) ) {
37
+ renderEmailEmptyError ( ) ;
38
+ } else if ( isNewEmail ( email ) ) {
39
+ renderSuccess ( ) ;
40
+ } else {
41
+ renderEmailTakenError ( ) ;
42
+ }
33
43
} ) ;
34
44
35
45
let toggleNav = ( ) => {
You can’t perform that action at this time.
0 commit comments