Skip to content

Commit 00236e5

Browse files
signup form created
1 parent c4f1945 commit 00236e5

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React,{useState} from 'react';
2+
3+
const Register = () => {
4+
5+
const [info,setInfo] = useState({name:"",email:"",password:"",error:"",loading:false,message:"",showForm:true});
6+
7+
const {name,email,password,error,loading,message,showForm} = info
8+
9+
const handleSubmit=(event)=>{
10+
event.preventDefault();
11+
console.table({name,email,password,error,loading,message,showForm})
12+
}
13+
14+
const handleChange= name =>(event)=>{
15+
setInfo({...info,error:false,[name]: e.target.value});
16+
}
17+
const registerForm=()=>{
18+
return (
19+
<form onSubmit={handleSubmit}>
20+
{/* Name */}
21+
<div className="form-group">
22+
{/* dynamic handle change by passing the value straight to it */}
23+
<input type="text" value={name} className="form-control" onChange={handleChange("name")} placeholder="Enter Your Name"/>
24+
</div>
25+
{/* Email */}
26+
<div className="form-group">
27+
<input type="email" value={email} className="form-control" onChange={handleChange("email")} placeholder="Enter Your @Email address"/>
28+
</div>
29+
{/* Password */}
30+
<div className="form-group">
31+
<input type="password" value={password} className="form-control" onChange={handleChange("password")} placeholder="Enter Your password"/>
32+
</div>
33+
<button className="btn btn-info">Register</button>
34+
</form>
35+
)
36+
}
37+
return (
38+
<>
39+
{registerForm()}
40+
</>
41+
)
42+
}
43+
44+
export default Register

client/pages/signup.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import Layout from "../components/Layout";
1+
import React from "react";
2+
import Layout from "../components/Layout";
3+
import Register from "../components/authentication/Register";
24
import Link from "next/link";
35

46
const Signup =() =>{
57
return(
68
<Layout>
79
<Link href="/"><a>Home</a></Link>
8-
<h2>Signup page</h2>
10+
<Register/>
911
</Layout>
1012
)
1113
}

0 commit comments

Comments
 (0)