-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,61 @@ | ||
import React, { useState } from 'react'; | ||
import { useNavigate } from "react-router-dom"; | ||
import { Form, Button, Card } from "react-bootstrap"; | ||
import { addUser } from '../Services/TF-db_services'; | ||
|
||
function SignUpPage() { | ||
const [email, setEmail] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [confirmPassword, setConfirmPassword] = useState(''); | ||
const navigate = useNavigate(); | ||
|
||
const handleSubmit = async (event) => { | ||
event.preventDefault(); | ||
if (password !== confirmPassword) { | ||
alert('Passwords do not match'); | ||
return; | ||
} | ||
const user = { | ||
email: email, | ||
password: password | ||
}; | ||
const addedUser = await addUser(user); | ||
if (addedUser) { | ||
alert('User added:', addedUser); | ||
navigate('/'); | ||
} else { | ||
console.error('Error adding user'); | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<Card style={{ width: '35rem', margin: '0 auto', float: 'none' }}> | ||
<Form className="form-group"> | ||
<Form onSubmit={handleSubmit} className="form-group"> | ||
<Form.Group className="mb-3" controlId="formBasicEmail"> | ||
<Form.Label>Email address</Form.Label> | ||
<Form.Control className="Form-Control" type="email" placeholder="Enter email" /> | ||
<Form.Control type="email" placeholder="Enter email" value={email} onChange={(e) => setEmail(e.target.value)} /> | ||
<Form.Text className="text-muted"> | ||
We'll never share your email with anyone else. | ||
</Form.Text> | ||
</Form.Group> | ||
|
||
<Form.Group className="mb-3" controlId="formBasicPassword"> | ||
<Form.Label>Password</Form.Label> | ||
<Form.Control type="password" placeholder="Password" /> | ||
<Form.Control type="password" placeholder="Password" value={password} onChange={(e) => setPassword(e.target.value)} /> | ||
</Form.Group> | ||
<Form.Group className="mb-3" controlId="formBasicPassword"> | ||
|
||
<Form.Group className="mb-3" controlId="formBasicConfirmPassword"> | ||
<Form.Label>Confirm Password</Form.Label> | ||
<Form.Control type="password" placeholder="Confirm Password" /> | ||
<Form.Control type="password" placeholder="Confirm Password" value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} /> | ||
</Form.Group> | ||
|
||
<Button variant="primary" type="submit"> | ||
Create Account | ||
</Button> | ||
</Form> | ||
</Card> | ||
</> | ||
|
||
); | ||
|
||
} | ||
export default SignUpPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters