-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Jugador7/retry
Retry
- Loading branch information
Showing
167 changed files
with
32,678 additions
and
44 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
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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useState } from "react"; | ||
import "./Register.css"; | ||
import user_icon from "../assets/person.png" | ||
import email_icon from "../assets/email.png" | ||
import password_icon from "../assets/password.png" | ||
import close_icon from "../assets/close.png" | ||
|
||
const Register = () => { | ||
const [userName, setUserName] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const [email, setEmail] = useState(""); | ||
const [firstName, setFirstName] = useState(""); | ||
const [lastName, setlastName] = useState(""); | ||
|
||
const gohome = () => { | ||
window.location.href = window.location.origin; | ||
} | ||
|
||
const register = async (e) => { | ||
e.preventDefault(); | ||
|
||
let register_url = window.location.origin + "/djangoapp/register/"; // Ensure trailing slash | ||
|
||
const res = await fetch(register_url, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
"userName": userName, | ||
"password": password, | ||
"firstName": firstName, | ||
"lastName": lastName, | ||
"email": email | ||
}), | ||
}); | ||
|
||
const json = await res.json(); | ||
if (json.status) { | ||
sessionStorage.setItem('username', json.userName); | ||
window.location.href = window.location.origin; | ||
} | ||
else if (json.error === "Already Registered") { | ||
alert("The user with the same username is already registered"); | ||
window.location.href = window.location.origin; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="register_container" style={{ width: "50%" }}> | ||
<div className="header" style={{ display: "flex", flexDirection: "row", justifyContent: "space-between" }}> | ||
<span className="text" style={{ flexGrow: "1" }}>SignUp</span> | ||
<div style={{ display: "flex", flexDirection: "row", justifySelf: "end", alignSelf: "start" }}> | ||
<a href="/" onClick={() => { gohome() }} style={{ justifyContent: "space-between", alignItems: "flex-end" }}> | ||
<img style={{ width: "1cm" }} src={close_icon} alt="X" /> | ||
</a> | ||
</div> | ||
<hr /> | ||
</div> | ||
|
||
<form onSubmit={register}> | ||
<div className="inputs"> | ||
<div className="input"> | ||
<img src={user_icon} className="img_icon" alt='Username' /> | ||
<input type="text" name="username" placeholder="Username" className="input_field" onChange={(e) => setUserName(e.target.value)} /> | ||
</div> | ||
<div> | ||
<img src={user_icon} className="img_icon" alt='First Name' /> | ||
<input type="text" name="first_name" placeholder="First Name" className="input_field" onChange={(e) => setFirstName(e.target.value)} /> | ||
</div> | ||
|
||
<div> | ||
<img src={user_icon} className="img_icon" alt='Last Name' /> | ||
<input type="text" name="last_name" placeholder="Last Name" className="input_field" onChange={(e) => setlastName(e.target.value)} /> | ||
</div> | ||
|
||
<div> | ||
<img src={email_icon} className="img_icon" alt='Email' /> | ||
<input type="email" name="email" placeholder="email" className="input_field" onChange={(e) => setEmail(e.target.value)} /> | ||
</div> | ||
|
||
<div className="input"> | ||
<img src={password_icon} className="img_icon" alt='password' /> | ||
<input name="psw" type="password" placeholder="Password" className="input_field" onChange={(e) => setPassword(e.target.value)} /> | ||
</div> | ||
|
||
</div> | ||
<div className="submit_panel"> | ||
<input className="submit" type="submit" value="Register" /> | ||
</div> | ||
</form> | ||
</div> | ||
) | ||
} | ||
|
||
export default Register; |
Oops, something went wrong.