Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestang06 committed Jan 14, 2024
2 parents 9825bc1 + d0074b7 commit 7b70b06
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 153 deletions.
2 changes: 1 addition & 1 deletion src/components/Authorization/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./Login.css";

// IMAGES
import pageImage from "../../assets/images/cover-image.jpeg";
import LoginView from "./LoginView/Login";
import LoginView from "./LoginView/LoginView";
import { useNavigate } from "react-router";

// LOGIN PAGE
Expand Down
3 changes: 0 additions & 3 deletions src/components/Authorization/LoginView/Login.css

This file was deleted.

124 changes: 0 additions & 124 deletions src/components/Authorization/LoginView/Login.jsx

This file was deleted.

8 changes: 8 additions & 0 deletions src/components/Authorization/LoginView/LoginView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.br-10 {
border-radius: 50px;
}

.ant-col.ant-form-item-label {
padding: 0 !important;
}

127 changes: 127 additions & 0 deletions src/components/Authorization/LoginView/LoginView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// IMPORTS
import { Button, Form, Input } from "antd";
import { auth, logInWithEmailAndPassword, loginWithMicrosoft, registerWithEmailAndPassword } from "../../../Firebase";
// IMAGES
// import publicLogo from "../../../assets/images/public.png";
import microsoft from "../../../assets/images/Microsoft_icon.svg.png";
import { useNavigate } from "react-router";
import "./LoginView.css";
import { useEffect, useState } from "react";
import { useAuthState } from "react-firebase-hooks/auth";

import publicLogo from "../../../assets/images/logo-black.png";

// ADMIN LOGIN VIEW
function LoginView(props) {
const navigate = useNavigate();

let [tab, setTab] = useState(false);

let [email, setEmail] = useState("");
let [password, setPassword] = useState("");

let [user, loading] = useAuthState(auth);

const login = (values) => {

tab === false ? logInWithEmailAndPassword(email, password) : registerWithEmailAndPassword(email, password);
};

const register = (values) => {
registerWithEmailAndPassword(email, password);
}


useEffect(() => {
if (user) {
navigate("/dashboard");
}
}
, [user]);


// DISPLAY ADMIN LOGIN VIEW
return props.show ? (
<div className="login">
<div className="login__container">
<img className="coverLogo" src={publicLogo}></img>
<Form
layout='vertical'
name="basic"
className="login_form"
style={{
width: 300,
}}
initialValues={{
remember: true,
}}
autoComplete="off"
size="large"
onFinish={login}
>
<p className="padded-text">
WPI Roadmap is a universal solution to introduce you to WPI's major requirement system. Developed by WPI students for WPI students (GoatHacks 2024).
</p>
<Form.Item
label="Email"
style={{marginTop:0, fontWeight:"bold"}}
wrapperCol={{
span: 20,
}}
>
<Input
size="large"
className="br-10 my-2"
style={{ width: 300 }}
onChange={(e) => {
setEmail(e.target.value);
}}
></Input>
</Form.Item>
<Form.Item
label="Password"
style={{marginTop:0, fontWeight:"bold"}}
>
<Input.Password
size="large"
className="br-10 my-3"
style={{ width: 300 }}
onChange={(e) => {
setPassword(e.target.value);
}
}
></Input.Password>
</Form.Item>
<Form.Item>
<Button
type="primary"
className="microsoft"
htmlType="submit"

>
{/* <img src={microsoft} height={"20px"} className="msft"></img> */}
{tab === false ? "Login" : "Register"}
</Button>
</Form.Item>
</Form>
<p className="footerText mx-auto">
<a className="link" onClick={() => setTab(!tab)} target="0">
{tab === false ? "Register" : "Back to login"}
</a>{" "}
{/* •{" "}
<a className="link" href="" target="0">
Privacy policy
</a>{" "} */}
{" "}
<a className="link" href="https://github.com/WPI-Roadmap" target="0">
Github
</a>{" "}
</p>
</div>
</div>
) : (
<></>
);
}

export default LoginView;
2 changes: 1 addition & 1 deletion src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ function Dashboard() {

<Form.Item>
<Button type="primary" htmlType="submit" onClick={() => { signupyayslay() }}>
Signup
Sign Up
</Button>
</Form.Item>
</Form>
Expand Down
Loading

0 comments on commit 7b70b06

Please sign in to comment.