File tree Expand file tree Collapse file tree 2 files changed +32
-27
lines changed Expand file tree Collapse file tree 2 files changed +32
-27
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ import {setToken} from '@/app/services/login-store'
17
17
import { useRouter } from "next/navigation" ;
18
18
19
19
type InputFields = {
20
- email ? : string
21
- password ? : string
20
+ email : string
21
+ password : string
22
22
}
23
23
24
24
export default function Home ( ) {
@@ -35,11 +35,6 @@ export default function Home() {
35
35
} ;
36
36
37
37
function submitDetails ( { email, password} : InputFields ) : void {
38
- if ( ! email || email === "" ||
39
- ! password || password === ""
40
- ) {
41
- return ;
42
- }
43
38
loginUser ( email , password ) . then ( jwt => {
44
39
successMessage ( "Login successful" )
45
40
setToken ( jwt ) ;
@@ -65,12 +60,15 @@ export default function Home() {
65
60
>
66
61
< Form . Item < InputFields >
67
62
name = "email"
68
- rules = { [ {
63
+ rules = { [
64
+ {
69
65
required : true ,
70
66
message : "Please provide your email."
71
- } ] }
67
+ } ,
68
+ ] }
72
69
>
73
70
< Input
71
+ type = "email"
74
72
placeholder = "Email"
75
73
/>
76
74
</ Form . Item >
Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ import { createUser } from '@/app/services/user'
16
16
import { useRouter } from "next/navigation" ;
17
17
18
18
type InputFields = {
19
- username ? : string
20
- email ? : string
21
- password ? : string
22
- confirmPassword ? : string
19
+ username : string
20
+ email : string
21
+ password : string
22
+ confirmPassword : string
23
23
}
24
24
25
25
export default function Home ( ) {
@@ -36,12 +36,6 @@ export default function Home() {
36
36
} ;
37
37
38
38
function submitDetails ( { username, email, password} : InputFields ) : void {
39
- if ( ! username || username === "" ||
40
- ! email || email === "" ||
41
- ! password || password === ""
42
- ) {
43
- return ;
44
- }
45
39
createUser ( username , email , password )
46
40
. then ( ( ) => {
47
41
successMessage ( "Account successfully created" )
@@ -68,10 +62,16 @@ export default function Home() {
68
62
69
63
< Form . Item < InputFields >
70
64
name = "username"
71
- rules = { [ {
72
- required : true ,
73
- message : "You must provide a username."
74
- } ] }
65
+ rules = { [
66
+ {
67
+ required : true ,
68
+ message : "You must provide a username."
69
+ } ,
70
+ {
71
+ pattern : / ^ \S + $ / ,
72
+ message : "Please provide a valid username."
73
+ } ,
74
+ ] }
75
75
>
76
76
< Input
77
77
placeholder = "Username"
@@ -80,12 +80,19 @@ export default function Home() {
80
80
81
81
< Form . Item < InputFields >
82
82
name = "email"
83
- rules = { [ {
84
- required : true ,
85
- message : "You must provide an email."
86
- } ] }
83
+ rules = { [
84
+ {
85
+ required : true ,
86
+ message : "You must provide an email."
87
+ } ,
88
+ {
89
+ type : "email" ,
90
+ message : "Please provide a valid email address."
91
+ } ,
92
+ ] }
87
93
>
88
94
< Input
95
+ type = "email"
89
96
placeholder = "Email"
90
97
/>
91
98
</ Form . Item >
You can’t perform that action at this time.
0 commit comments