-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
dfdcd86
commit 8cac417
Showing
15 changed files
with
288 additions
and
95 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React, { useState } from 'react'; | ||
import axios from 'axios'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
const SignUpForm = () => { | ||
const [email, setEmail] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [validSubmit, setValidSubmit] = useState(''); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const submitForm = async () => { | ||
if (email && password) { | ||
try { | ||
await axios.post( | ||
`${import.meta.env.VITE_SERVER_URL}/api/user`, | ||
{ | ||
email, | ||
password, | ||
}, | ||
|
||
); | ||
navigate('/'); | ||
} catch (error) { | ||
console.error('Error submitting form:', error); | ||
setValidSubmit('error'); | ||
} | ||
} else { | ||
setValidSubmit('error'); | ||
} | ||
}; | ||
|
||
const handleEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setEmail(e.target.value); | ||
}; | ||
|
||
const handlePasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setPassword(e.target.value); | ||
}; | ||
|
||
return ( | ||
<div className="qr-code-form"> | ||
<h1 className="header">Sign Up</h1> | ||
{validSubmit === 'error' && ( | ||
<p className="error-msg">Please fill in the required areas correctly</p> | ||
)} | ||
|
||
<div className="form-form"> | ||
<div className="input-section"> | ||
<label className="input-label" htmlFor="email"> | ||
</label> | ||
<input | ||
className="input-fields" | ||
id="email" | ||
type="text" | ||
placeholder="example@gmail.com" | ||
value={email} | ||
onChange={handleEmailChange} | ||
/> | ||
</div> | ||
|
||
<div className="input-section"> | ||
<label className="input-label" htmlFor="password"> | ||
Password | ||
</label> | ||
<input | ||
className="input-fields" | ||
id="password" | ||
type="password" | ||
placeholder="*******" | ||
value={password} | ||
onChange={handlePasswordChange} | ||
/> | ||
</div> | ||
|
||
<div className="submit-button-container"> | ||
<div className="submit-link"> | ||
<button className="submit-button" onClick={submitForm}> | ||
Submit! | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SignUpForm; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import QRCodeForm from "../components/sign-up"; | ||
import '../styles/form.css'; | ||
|
||
function Form() { | ||
return ( | ||
<div className='form-outer background-form'> | ||
<div className='form-inner'> | ||
<QRCodeForm /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Form; |
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
Oops, something went wrong.