Skip to content

Commit 45ee407

Browse files
author
Aishwarya Nair
committed
separate log in and sign up forms
1 parent 12aad40 commit 45ee407

File tree

3 files changed

+118
-58
lines changed

3 files changed

+118
-58
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from 'react'
2+
import './LoginSignUp.css'
3+
import {useState} from 'react'
4+
import { useNavigate } from "react-router-dom";
5+
6+
import password_icon from '../Assets/password.png'
7+
import user_icon from '../Assets/user.png'
8+
9+
import { loginUser } from '../../User/UserServiceAPI'
10+
import {resetUserPasswordUsingFirebase} from "../../Authentication/UserAuthenticationController"
11+
12+
export const Login = ({setAction}) => {
13+
const navigate = useNavigate();
14+
15+
const [action, setAction] = useState("Log In");
16+
17+
const [userEmail, setUserEmail] = useState("");
18+
const [userPassword, setUserPassword] = useState("");
19+
20+
21+
return (
22+
<div>
23+
<div className="inputs">
24+
<div className="input">
25+
<div className="input-container">
26+
<img src= {user_icon} alt="" />
27+
<input type="text" placeholder = "Email" onChange={(e) => {setUserEmail(e.target.value);}} value={userEmail}/>
28+
</div>
29+
</div>
30+
<div className="input">
31+
<div className="input-container">
32+
<img src= {password_icon} alt="" />
33+
<input type="password" placeholder = "Password" onChange={(e) => {setUserPassword(e.target.value);}} value={userPassword}/>
34+
</div>
35+
</div>
36+
37+
</div>
38+
<div className="forgot-password"> Forgot Password? <span onClick={()=>resetUserPasswordUsingFirebase(userEmail)}> Click Here.</span></div>
39+
<div className="submit-container">
40+
<div className="submit"
41+
onClick = {async () => {
42+
const result = await loginUser(userEmail, userPassword)
43+
if(result) {
44+
navigate("/landing");
45+
}
46+
}}>Log In</div>
47+
</div>
48+
<div className="signup-nav"> Don't have an account? <span onClick={()=>setAction("Sign Up")}> Sign Up.</span></div>
49+
</div>
50+
51+
)
52+
}
53+
54+

Frontend/src/Components/LoginSignUp/LoginSignUp.jsx

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,22 @@ import './LoginSignUp.css'
33
import {useState} from 'react'
44
import { useNavigate } from "react-router-dom";
55

6-
import password_icon from '../Assets/password.png'
7-
import user_icon from '../Assets/user.png'
8-
9-
import { registerUser, loginUser } from '../../User/UserServiceAPI'
10-
import {resetUserPasswordUsingFirebase} from "../../Authentication/UserAuthenticationController"
6+
import { Login } from './Login';
7+
import { SignUp } from './SignUp';
118

129
export const LoginSignUp = () => {
13-
const navigate = useNavigate();
14-
10+
1511
const [action, setAction] = useState("Log In");
1612

17-
const [userEmail, setUserEmail] = useState("");
18-
const [userPassword, setUserPassword] = useState("");
19-
const [userName, setUserName] = useState("");
20-
const [preferredLang, setPreferredLang] = useState("");
21-
2213
return (
2314
<div className="container-login">
2415
<div className="header">
2516
<div className="text"> {action} </div>
2617
<div className="underline"></div>
2718
</div>
28-
<div className="inputs">
29-
<div className="input">
30-
<div className="input-container">
31-
<img src= {user_icon} alt="" />
32-
<input type="text" placeholder = "Email" onChange={(e) => {setUserEmail(e.target.value);}} value={userEmail}/>
33-
</div>
34-
</div>
35-
<div className="input">
36-
<div className="input-container">
37-
<img src= {password_icon} alt="" />
38-
<input type="password" placeholder = "Password" onChange={(e) => {setUserPassword(e.target.value);}} value={userPassword}/>
39-
</div>
40-
</div>
41-
{action === "Sign Up"?
42-
<div className="input">
43-
<input type="text" placeholder = "Name" onChange={(e) => {setUserName(e.target.value);}} value={userName}/>
44-
</div>:
45-
<div></div>}
46-
{action === "Sign Up"?
47-
<div className="input">
48-
<input type="text" placeholder = "Preferred programming language" onChange={(e) => {setPreferredLang(e.target.value);}} value={preferredLang}/>
49-
</div>:
50-
<div></div>}
51-
</div>
52-
{action === "Sign Up" ? <div></div>: <div className="forgot-password" onClick={()=>resetUserPasswordUsingFirebase(userEmail)}> Forgot Password? <span> Click Here.</span></div>}
53-
<div className="submit-container">
54-
<div className={action==="Sign Up"? "submit gray": "submit"}
55-
onClick = {async () => {
56-
setAction("Log In")
57-
const result = await loginUser(userEmail, userPassword)
58-
59-
if(result) {
60-
navigate("/landing");
61-
}
62-
}}>Log In</div>
63-
<div className={action==="Log In"? "submit gray": "submit"}
64-
onClick = {async () => {
65-
setAction("Sign Up")
66-
const result = await registerUser(userName, userEmail, userPassword, "GitHub ID Placeholder", preferredLang)
67-
68-
if(result) {
69-
navigate("/landing");
70-
}
71-
}}>Sign Up</div>
72-
</div>
19+
{action === "Log In"? <Login setAction={setAction}/>: <SignUp setAction={setAction}/>}
20+
7321
</div>
74-
7522
)
7623
}
7724

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react'
2+
import './LoginSignUp.css'
3+
import {useState} from 'react'
4+
import { useNavigate } from "react-router-dom";
5+
6+
import password_icon from '../Assets/password.png'
7+
import user_icon from '../Assets/user.png'
8+
9+
import { registerUser } from '../../User/UserServiceAPI'
10+
11+
12+
export const SignUp = (setAction) => {
13+
const navigate = useNavigate();
14+
15+
const [userEmail, setUserEmail] = useState("");
16+
const [userPassword, setUserPassword] = useState("");
17+
const [userName, setUserName] = useState("");
18+
const [preferredLang, setPreferredLang] = useState("");
19+
20+
return (
21+
<div>
22+
<div className="inputs">
23+
<div className="input">
24+
<div className="input-container">
25+
<img src= {user_icon} alt="" />
26+
<input type="text" placeholder = "Email" onChange={(e) => {setUserEmail(e.target.value);}} value={userEmail}/>
27+
</div>
28+
</div>
29+
<div className="input">
30+
<div className="input-container">
31+
<img src= {password_icon} alt="" />
32+
<input type="password" placeholder = "Password" onChange={(e) => {setUserPassword(e.target.value);}} value={userPassword}/>
33+
</div>
34+
</div>
35+
<div className="input">
36+
<input type="text" placeholder = "Name" onChange={(e) => {setUserName(e.target.value);}} value={userName}/>
37+
</div>
38+
<div className="input">
39+
<input type="text" placeholder = "Preferred programming language" onChange={(e) => {setPreferredLang(e.target.value);}} value={preferredLang}/>
40+
</div>
41+
</div>
42+
43+
<div className="submit-container">
44+
<div className= "submit"
45+
onClick = {async () => {
46+
const result = await registerUser(userName, userEmail, userPassword, "GitHub ID Placeholder", preferredLang)
47+
48+
if(result) {
49+
navigate("/landing");
50+
}
51+
}}>Sign Up</div>
52+
</div>
53+
<div className="login-nav"> Already have an account? <span onClick={()=>setAction("Log In")}> Log In.</span></div>
54+
</div>
55+
56+
)
57+
}
58+
59+

0 commit comments

Comments
 (0)