-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignup.jsx
More file actions
148 lines (131 loc) · 4.97 KB
/
Signup.jsx
File metadata and controls
148 lines (131 loc) · 4.97 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import React from 'react'
import { Button, Form, Icon } from 'semantic-ui-react'
import './Signup.css'
import Image from './Image'
import { useState } from "react"
import { createAuthUserWithEmailAndPassword, createuserdocfromAuth } from "./Auth/Firebase";
import { Link } from 'react-router-dom'
function Signup() {
const [contact, setcontact] = useState({
displayName: '',
email: '',
password: '',
confirmPassword: ''
})
const [isChecked, setIsChecked] = useState(false);
function handleCheckboxChange() {
setIsChecked(!isChecked);
}
const { displayName, email, password, confirmPassword } = contact
console.log(contact)
async function handleClick() {
if (!isChecked) {
alert('Please agree to the Terms and Conditions');
return;
}
if (password !== confirmPassword) {
alert('password do not match')
return;
}
try {
const { user } = await createAuthUserWithEmailAndPassword(email, password)
await createuserdocfromAuth(user, { displayName })
console.log(user)
return;
}
catch (error) {
console.log('error in creation', error.message)
}
}
function handlepass(event) {
const value = event.target.value
const name = event.target.name
setcontact((prevalue) => {
return {
...prevalue,
[name]: value
}
})
}
return (<body>
<div className="b3">
<Link to='/login'>
<Button animated size=''>
<Button.Content visible>Back</Button.Content>
<Button.Content hidden>
<Icon name='backward' />
</Button.Content>
</Button>
</Link>
</div>
<div className='all'>
<div className="container2">
<div className="title">
<h3> Create a DEV@DEAKIN Account</h3>
</div>
<Form>
<Form.Group >
<div className="n">
<div className="N_label">
<label >Name</label >
</div>
<div className="name_input">
<input name='displayName' type='text'
placeholder='name' onChange={handlepass} />
</div>
</div>
</Form.Group>
<Form.Group >
<div className="n">
<div className="N_label">
<label >Email</label >
</div>
<div className="E_input">
<input name='email'
type='email'
placeholder='email' onChange={handlepass} />
</div>
</div>
</Form.Group>
<Form.Group >
<div className="n">
<div className="N_label">
<label >Password</label >
</div>
<div className="p_input">
<input name='password'
type='password'
placeholder='password' onChange={handlepass} />
</div>
</div>
</Form.Group>
<Form.Group >
<div className="n">
<div className="N_label">
<label >Confirm Password</label >
</div>
<div className="c_p_input">
<input name='confirmPassword'
type='password'
placeholder='confirmPassword' onChange={handlepass} />
</div>
</div>
</Form.Group>
<div className="checkbox">
<Form.Checkbox label='I agree to the Terms and Conditions'
checked={isChecked} onChange={handleCheckboxChange} />
</div>
<br></br>
<Link to='/login'>
<div className="l">
<Button onClick={handleClick} >Create</Button>
</div>
</Link>
<br></br>
</Form>
</div>
</div>
</body>
)
}
export default Signup