diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js
index 19f903e..16dc73a 100644
--- a/src/components/Dashboard/Dashboard.js
+++ b/src/components/Dashboard/Dashboard.js
@@ -45,14 +45,14 @@ function Dashboard() {
let [major, setMajor] = useState("");
- console.log(user)
+ // console.log(user)
useEffect(() => {
- console.log(logoutUser)
+ // console.log(logoutUser)
if (user == null && logoutUser) {
navigate("/");
setLogout(false);
}
-
+
}, [user]);
@@ -237,7 +237,6 @@ function Dashboard() {
setSignup(true);
}
});
-
});
const services = [
@@ -372,24 +371,23 @@ function Dashboard() {
const getUserInfo = () => {
try {
- RequestUtils.get('/retrieve?id=' + user.uid).then((response) => response.json())
- .then((data) => {
- console.log(data.status)
- if (data.status == 200) {
- setFirst(data.data.name);
- setLast(data.data.last);
- setYear(data.data.year);
- setMajor(data.data.major);
- }
- if(data.status == 404) {
- console.log(data.status)
- setSignup(true);
- }
- });
- } catch {
-
- }
-
+ RequestUtils.get('/retrieve?id=' + user.uid).then((response) => response.json())
+ .then((data) => {
+ console.log(data.status)
+ if (data.status == 200) {
+ setFirst(data.data.name);
+ setLast(data.data.last);
+ setYear(data.data.year);
+ setMajor(data.data.major);
+ }
+ if (data.status == 404) {
+ console.log(data.status)
+ setSignup(true);
+ }
+ });
+ } catch {
+ console.log("Error in retrieving user info.")
+ }
}
@@ -478,8 +476,8 @@ function Dashboard() {
onClick: () => {
logout();
setLogout(true);
-
-
+
+
}
}
@@ -515,7 +513,8 @@ function Dashboard() {
) : (
<>
-
+
+ {/*first={first} setFirst={setFirst} last={last} setLast={setLast} year={year} setYear={setYear} major={major} setMajor={setMajor} */}
>
)}
diff --git a/src/components/Dashboard/Profile.js b/src/components/Dashboard/Profile.js
index d1fe229..94e7a15 100644
--- a/src/components/Dashboard/Profile.js
+++ b/src/components/Dashboard/Profile.js
@@ -1,16 +1,63 @@
import { useState, useEffect, useLayoutEffect } from "react";
import { useNavigate } from "react-router";
import { Button, Form, Input, Select } from "antd";
+import RequestUtils from "../../Utils/RequestUtils.js";
+import { auth, logout } from "../../Firebase.js";
+import { useAuthState } from "react-firebase-hooks/auth";
-function Profile({ first, setFirst, last, setLast, year, setYear, major, setMajor }) {
-
+function Profile({ }) {
+ // first, setFirst, last, setLast, year, setYear, major, setMajor
const { Option } = Select;
+ let [user, loading] = useAuthState(auth);
+
+ let [first, setFirst] = useState("");
+ let [last, setLast] = useState("");
+ let [year, setYear] = useState("");
+ let [major, setMajor] = useState("");
+
+ const signupyayslay = () => {
+ let reqbody = {
+ first: first,
+ last: last,
+ email: user.email,
+ year: year,
+ major: major,
+ }
+ RequestUtils.post('/user?id=' + user.uid, reqbody)
+ }
+
+ useEffect(() => {
+ if (user != null) {
+ getUserInfo();
+ }
+
+ }, [user]);
+
+ const getUserInfo = () => {
+ try {
+ RequestUtils.get('/retrieve?id=' + user.uid).then((response) => response.json())
+ .then((data) => {
+ console.log(data.status)
+ if (data.status == 200) {
+ setFirst(data.data.name);
+ setLast(data.data.last);
+ setYear(data.data.year);
+ setMajor(data.data.major);
+ }
+ if (data.status == 404) {
+ console.log(data.status)
+ }
+ });
+ } catch {
+ console.log("Error in retrieving user info.")
+ }
+ }
return (
- <>
-
-
-
+ <>
+
+
+
Profile
- {
+ {
setLast(e.target.value)
}}
/>