diff --git a/src/components/Authorization/Login.js b/src/components/Authorization/Login.js index 281279f..2ff550f 100644 --- a/src/components/Authorization/Login.js +++ b/src/components/Authorization/Login.js @@ -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 diff --git a/src/components/Authorization/LoginView/Login.css b/src/components/Authorization/LoginView/Login.css deleted file mode 100644 index d2af6b6..0000000 --- a/src/components/Authorization/LoginView/Login.css +++ /dev/null @@ -1,3 +0,0 @@ -.br-10 { - border-radius: 50px; -} \ No newline at end of file diff --git a/src/components/Authorization/LoginView/Login.jsx b/src/components/Authorization/LoginView/Login.jsx deleted file mode 100644 index defdb90..0000000 --- a/src/components/Authorization/LoginView/Login.jsx +++ /dev/null @@ -1,124 +0,0 @@ -// 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 "./Login.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 ? ( -
-
- -
-

- Welcome to Roadmap-WPI -

-

- A universal solution to introduce you to WPI's major requirement system Developed by WPI students for WPI students (GoatHacks 2024). -

- - { - setEmail(e.target.value); - }} - > - - - { - setPassword(e.target.value); - } - } - > - - - - -
-

- setTab(!tab)} target="0"> - {tab === false ? "Register" : "Back to login"} - {" "} - •{" "} - - Privacy policy - {" "} - •{" "} - - Github - {" "} -

-
-
- ) : ( - <> - ); -} - -export default LoginView; diff --git a/src/components/Authorization/LoginView/LoginView.css b/src/components/Authorization/LoginView/LoginView.css new file mode 100644 index 0000000..f0e3faa --- /dev/null +++ b/src/components/Authorization/LoginView/LoginView.css @@ -0,0 +1,8 @@ +.br-10 { + border-radius: 50px; +} + +.ant-col.ant-form-item-label { + padding: 0 !important; +} + diff --git a/src/components/Authorization/LoginView/LoginView.jsx b/src/components/Authorization/LoginView/LoginView.jsx new file mode 100644 index 0000000..6210221 --- /dev/null +++ b/src/components/Authorization/LoginView/LoginView.jsx @@ -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 ? ( +
+
+ +
+

+ WPI Roadmap is a universal solution to introduce you to WPI's major requirement system. Developed by WPI students for WPI students (GoatHacks 2024). +

+ + { + setEmail(e.target.value); + }} + > + + + { + setPassword(e.target.value); + } + } + > + + + + +
+

+ setTab(!tab)} target="0"> + {tab === false ? "Register" : "Back to login"} + {" "} + {/* •{" "} + + Privacy policy + {" "} */} + •{" "} + + Github + {" "} +

+
+
+ ) : ( + <> + ); +} + +export default LoginView; diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index 16dc73a..2228152 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -586,7 +586,7 @@ function Dashboard() { diff --git a/src/components/Table/Table.jsx b/src/components/Table/Table.jsx index 39d8451..672d5a4 100644 --- a/src/components/Table/Table.jsx +++ b/src/components/Table/Table.jsx @@ -1,5 +1,9 @@ import React, { useContext, useEffect, useRef, useState } from 'react'; import { Button, Form, Input, Popconfirm, Table } from 'antd'; +import RequestUtils from '../../Utils/RequestUtils'; +import { auth } from '../../Firebase'; + +import { useAuthState } from 'react-firebase-hooks/auth'; const EditableContext = React.createContext(null); const EditableRow = ({ index, ...props }) => { const [form] = Form.useForm(); @@ -42,6 +46,15 @@ const EditableCell = ({ ...record, ...values, }); + let fullObj = {...record, ...values}; + + RequestUtils.post("/update", fullObj).then((response) => response.json()) + .then((data) => { + console.log(data); + }); + + console.log({...record, ...values}) + } catch (errInfo) { console.log('Save failed:', errInfo); } @@ -77,47 +90,76 @@ const EditableCell = ({ } return {childNode}; }; + + const App = () => { - const [dataSource, setDataSource] = useState([ - { - key: '0', - name: 'Edward King 0', - age: '32', - address: 'London, Park Lane no. 0', - }, - { - key: '1', - name: 'Edward King 1', - age: '32', - address: 'London, Park Lane no. 1', - }, - ]); + + let [ user, loading ] = useAuthState(auth); + const [dataSource, setDataSource] = useState([]); + + + useEffect(() => { + if (user) { + addData(); + } + + + }, [user]); + + function addData() { + let temp = []; + RequestUtils.get("/retrieve?id=" + user.uid).then((response) => response.json()) + .then((data) => { + try{ + for (let i = 0; i < data.data.courses.length; i++) { + temp.push({ + key: i, + id: user.uid, + course: data.data.courses[i].courseCode, + grade: data.data.courses[i].grade, + term: data.data.courses[i].term, + }) + } + } catch (err){ + console.log(err); + } + console.log(data.data.courses); + console.log(temp) + setDataSource(temp); + }); + } + + + const [count, setCount] = useState(2); const handleDelete = (key) => { const newData = dataSource.filter((item) => item.key !== key); setDataSource(newData); }; + const defaultColumns = [ { - title: 'Course Title', - dataIndex: 'name', + title: 'UserID', + dataIndex: "id", width: '30%', - editable: true, }, { - title: 'Term', - dataIndex: 'age', + title: 'Course Title', + dataIndex: 'course', + width: '10%', }, { - title: 'Grade', - dataIndex: 'address', + title: 'Term', + dataIndex: 'term', + editable: true, }, { - title: "Remove Course", - dataIndex: "remove", + title: 'Grade', + dataIndex: 'grade', + editable: true, }, { - title: 'operation', + title: 'Remove Course', dataIndex: 'operation', render: (_, record) => dataSource.length >= 1 ? ( @@ -127,6 +169,7 @@ const App = () => { ) : null, }, ]; + const handleAdd = () => { const newData = { key: count, @@ -137,6 +180,7 @@ const App = () => { setDataSource([...dataSource, newData]); setCount(count + 1); }; + const handleSave = (row) => { const newData = [...dataSource]; const index = newData.findIndex((item) => row.key === item.key); @@ -170,6 +214,7 @@ const App = () => { }); return (
+

Click on the cells below to add the term you plan to take the course as well as the grade you recieve.

'editable-row'}