forked from jayasree-g/Webathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistration.js
82 lines (69 loc) · 3.31 KB
/
Registration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, {useState, useEffect} from 'react'
import Login from './Login';
import {Link} from 'react-router-dom';
//import mail from "./images/email.png";
//import lock from "./images/lock.png";
//import profile from "./images/icon.jpg";
function Registration() {
const LOCAL_STORAGE_KEY = "Info";
const [Info, setInfo] = useState({
name:"",
email:"",
password:"",
profession:""
});
useEffect(() => {
const retriveContacts = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY));
if (retriveContacts) setInfo(retriveContacts);
}, [])
useEffect(()=>{
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(Info))
},[Info])
let register = (e) =>{
e.preventDefault()
if (!Info.name || !Info.email || !Info.password || !Info.profession) {
alert("Complete all the fields!!!")
return
}
}
return (
<form onSubmit={register}>
<div className='main'>
<div className='sub-main'>
<div>
<div>
<h1>Registration</h1>
<div>
<input type="text" placeholder='Enter Name' className='fill' value={Info.name} onChange={(e) => setInfo({...Info, name: e.target.value})}/>
</div>
<div className='mail-id'>
<input type="email" placeholder='Enter Email-id' className='fill' value={Info.email} onChange={(e) => setInfo({...Info, email: e.target.value})}/>
</div>
<div className='mail-id'>
<input type="password" placeholder='Enter New Password' className='fill' value={Info.password} onChange={(e) => setInfo({...Info, password: e.target.value})}/>
</div>
<div className='select'>
{/* <label className='plist'>Intrest</label> */}
<select value={Info.profession} onChange={(event) => setInfo({...Info, profession: event.target.value})}>
<option>Android Studio</option>
<option>ReactJS</option>
<option>Python</option>
<option>Machine Learning</option>
</select>
</div>
<div className='login-btn'>
<Link to='/home'>
<button type="submit">Register</button>
</Link>
</div>
<div className='reg-link'>
<p>If Account exist then</p><Link className='link' to='/login'><li>Login!!!</li></Link>
</div>
</div>
</div>
</div>
</div>
</form>
)
}
export default Registration