Skip to content

Commit

Permalink
signup form created
Browse files Browse the repository at this point in the history
  • Loading branch information
pramit-marattha committed Jan 13, 2021
1 parent c4f1945 commit 00236e5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
44 changes: 44 additions & 0 deletions client/components/authentication/Register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React,{useState} from 'react';

const Register = () => {

const [info,setInfo] = useState({name:"",email:"",password:"",error:"",loading:false,message:"",showForm:true});

const {name,email,password,error,loading,message,showForm} = info

const handleSubmit=(event)=>{
event.preventDefault();
console.table({name,email,password,error,loading,message,showForm})
}

const handleChange= name =>(event)=>{
setInfo({...info,error:false,[name]: e.target.value});
}
const registerForm=()=>{
return (
<form onSubmit={handleSubmit}>
{/* Name */}
<div className="form-group">
{/* dynamic handle change by passing the value straight to it */}
<input type="text" value={name} className="form-control" onChange={handleChange("name")} placeholder="Enter Your Name"/>
</div>
{/* Email */}
<div className="form-group">
<input type="email" value={email} className="form-control" onChange={handleChange("email")} placeholder="Enter Your @Email address"/>
</div>
{/* Password */}
<div className="form-group">
<input type="password" value={password} className="form-control" onChange={handleChange("password")} placeholder="Enter Your password"/>
</div>
<button className="btn btn-info">Register</button>
</form>
)
}
return (
<>
{registerForm()}
</>
)
}

export default Register
6 changes: 4 additions & 2 deletions client/pages/signup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Layout from "../components/Layout";
import React from "react";
import Layout from "../components/Layout";
import Register from "../components/authentication/Register";
import Link from "next/link";

const Signup =() =>{
return(
<Layout>
<Link href="/"><a>Home</a></Link>
<h2>Signup page</h2>
<Register/>
</Layout>
)
}
Expand Down

0 comments on commit 00236e5

Please sign in to comment.