From 91d22cb33a6abe58a6c2703f70fa5b52197c81d9 Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:17:16 -0400 Subject: [PATCH 01/13] Reorganize components in places that make more sense --- .../{UIElements => Profile}/ProfileAvatar.tsx | 0 .../Profile}/ProfileDescription.tsx | 8 +- .../Profile/ProfileOpportunities.js | 167 ------------------ .../Profile}/ProfileOpportunities.tsx | 2 +- .../components/UIElements/LargeTextCard.tsx} | 5 +- 5 files changed, 8 insertions(+), 174 deletions(-) rename src/shared/components/{UIElements => Profile}/ProfileAvatar.tsx (100%) rename src/{staff/components => shared/components/Profile}/ProfileDescription.tsx (82%) delete mode 100644 src/shared/components/Profile/ProfileOpportunities.js rename src/{staff/components => shared/components/Profile}/ProfileOpportunities.tsx (96%) rename src/{staff/components/LargeTextCard.js => shared/components/UIElements/LargeTextCard.tsx} (87%) diff --git a/src/shared/components/UIElements/ProfileAvatar.tsx b/src/shared/components/Profile/ProfileAvatar.tsx similarity index 100% rename from src/shared/components/UIElements/ProfileAvatar.tsx rename to src/shared/components/Profile/ProfileAvatar.tsx diff --git a/src/staff/components/ProfileDescription.tsx b/src/shared/components/Profile/ProfileDescription.tsx similarity index 82% rename from src/staff/components/ProfileDescription.tsx rename to src/shared/components/Profile/ProfileDescription.tsx index 10fbe213..fa25d1ad 100644 --- a/src/staff/components/ProfileDescription.tsx +++ b/src/shared/components/Profile/ProfileDescription.tsx @@ -8,9 +8,11 @@ const ProfileDescription = ({ name, department, description, website }) => {

{name}

{department}

{description}

- - {website} - + {website && website.length && ( + + {website} + + )} ); }; diff --git a/src/shared/components/Profile/ProfileOpportunities.js b/src/shared/components/Profile/ProfileOpportunities.js deleted file mode 100644 index 1ff23373..00000000 --- a/src/shared/components/Profile/ProfileOpportunities.js +++ /dev/null @@ -1,167 +0,0 @@ -import React from "react"; -import OpportunityActionCard from "./OpportunityActionCard"; -import { useState, useEffect } from "react"; - -const DUMMY_DATA = { - d1: [ - { - title: "Software Intern", - body: "Posted February 8, 2024", - attributes: ["Remote", "Paid", "Credits"], - activeStatus: true, - id: "o1", - }, - // create dummy data for the opportunities - { - title: "Biology Intern", - body: "Due February 2, 2024", - attributes: ["Paid", "Credits"], - activeStatus: true, - id: "o2", - }, - { - title: "Physics Intern", - body: "Due February 6, 2024", - attributes: ["Remote", "Paid", "Credits"], - activeStatus: true, - id: "o3", - }, - { - title: "Chemistry Intern", - body: "Due February 15, 2023", - attributes: ["Remote", "Paid", "Credits"], - activeStatus: true, - id: "o4", - }, - { - title: - "Mathematics Intern For the Sciences and Engineering Mathematics Intern For the Sciences and Engineering", - body: "Due February 1, 2024", - attributes: ["Remote", "Paid", "Credits"], - activeStatus: true, - id: "o5", - }, - ], -}; - -const ProfileOpportunities = ({ id }) => { - var [opportunities, setOpportunities] = useState(false); - - const fetchOpportunities = async (key) => { - // Consider moving the base URL to a configuration - const baseURL = `${process.env.REACT_APP_BACKEND_SERVER}`; - const url = `${baseURL}/getProfileOpportunities/${key}`; - - const response = await fetch(url); - - if (!response.ok) { - return false; - } - - const data = await response.json(); - console.log(data); - return data["data"]; - }; - - async function setData(key) { - const response = await fetchOpportunities(key); - response && setOpportunities(response); - response || setOpportunities("no response"); - } - - async function changeOpportunityActiveStatus(opportunityId, activeStatus) { - // send a request to the backend to deactivate the opportunity - // if the request is successful, then deactivate the opportunity from the list - const url = `${process.env.REACT_APP_BACKEND_SERVER}/changeActiveStatus`; - console.log(opportunities); - - const jsonData = { - oppID: opportunityId, - setStatus: !activeStatus, - authToken: "authTokenHere", - }; - - const response = await fetch(url, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(jsonData), - }); - - if (response.ok) { - const data = await response.json(); - - const newOpportunities = opportunities.map((opportunity) => - opportunity.id === opportunityId - ? { ...opportunity, activeStatus: data.activeStatus } // Spread operator for update - : opportunity, - ); - - setOpportunities(newOpportunities); - } - } - - async function deleteOpportunity(opportunityId) { - // send a request to the backend to delete the opportunity - // if the request is successful, then delete the opportunity from the list - - const url = `${process.env.REACT_APP_BACKEND_SERVER}/deleteOpportunity`; - - const jsonData = { id: opportunityId }; - - const response = await fetch(url, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(jsonData), - }); - - if (response) { - opportunities = opportunities.filter( - (opportunity) => opportunity.id !== opportunityId, - ); - } else { - alert("Failed to delete opportunity"); - } - - setOpportunities(opportunities); - console.log(opportunities); - } - - useEffect(() => { - setData(id); - }, []); - - var opportuntityList = ( -
-

Posted Opportunties

-
- {opportunities && - opportunities.map((opportunity) => ( - - ))} -
-
- ); - - return opportunities ? ( - opportuntityList - ) : opportunities === "no response" ? ( - "No opportunities found" - ) : ( - - ); -}; - -export default ProfileOpportunities; diff --git a/src/staff/components/ProfileOpportunities.tsx b/src/shared/components/Profile/ProfileOpportunities.tsx similarity index 96% rename from src/staff/components/ProfileOpportunities.tsx rename to src/shared/components/Profile/ProfileOpportunities.tsx index 054a5a67..cf1e41e2 100644 --- a/src/staff/components/ProfileOpportunities.tsx +++ b/src/shared/components/Profile/ProfileOpportunities.tsx @@ -1,5 +1,5 @@ import React from "react"; -import LargeTextCard from "./LargeTextCard"; +import LargeTextCard from "../UIElements/LargeTextCard.tsx"; import PropTypes from "prop-types"; import { useState, useEffect } from "react"; diff --git a/src/staff/components/LargeTextCard.js b/src/shared/components/UIElements/LargeTextCard.tsx similarity index 87% rename from src/staff/components/LargeTextCard.js rename to src/shared/components/UIElements/LargeTextCard.tsx index d63d246e..df6158c9 100644 --- a/src/staff/components/LargeTextCard.js +++ b/src/shared/components/UIElements/LargeTextCard.tsx @@ -8,9 +8,8 @@ const LargeTextCard = ({ to, title, due, pay, credits }) => {

100 ? "text-sm" : "text-lg font-bold" - } p-0 m-0`} + className={`${title.length > 100 ? "text-sm" : "text-lg font-bold" + } p-0 m-0`} > {title}

From c99a8501b12da1d2f5bda3fa746d1cefd308b913 Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:17:42 -0400 Subject: [PATCH 02/13] Update Profile page prepared for backend work on profile data --- src/shared/pages/Profile.js | 126 ----------------------------------- src/shared/pages/Profile.tsx | 51 ++++++++++++++ 2 files changed, 51 insertions(+), 126 deletions(-) delete mode 100644 src/shared/pages/Profile.js create mode 100644 src/shared/pages/Profile.tsx diff --git a/src/shared/pages/Profile.js b/src/shared/pages/Profile.js deleted file mode 100644 index deac5f14..00000000 --- a/src/shared/pages/Profile.js +++ /dev/null @@ -1,126 +0,0 @@ -import React, { useEffect } from "react"; -import { useState } from "react"; -import ProfileAvatar from "../components/UIElements/ProfileAvatar.tsx"; -import ProfileDescription from "../../staff/components/ProfileDescription.tsx"; -import ProfileOpportunities from "../../staff/components/ProfileOpportunities.tsx"; -import EditProfile from "./EditProfile"; -import useGlobalContext from "../../context/global/useGlobalContext"; - -const PROFILES = { - d1: { - name: "Peter Johnson", - image: "https://www.bu.edu/com/files/2015/08/Katz-James-3.jpg", - researchCenter: "Computational Fake Center", - department: "Computer Science", - email: "johnp@rpi.edu", - role: "admin", - description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut - pharetra sit amet aliquam id diam maecenas ultricies mi. Montes - nascetur ridiculus mus mauris vitae ultricies leo. Porttitor massa - id neque aliquam. Malesuada bibendum arcu vitae elementum. Nulla - aliquet porrsus mattis molestie aiaculis at erat pellentesque. - At risus viverra adipiscing at. - Tincidunt tortor aliquam nulla facilisi cras fermentum odio eu - feugiat. Eget fUt eu sem integer vitae justo - eget magna fermentum. Lobortis feugiat vivamus at augue eget arcu - dictum. Et tortor at risus viverra adipiscing at in tellus. - Suspendisse sed nisi lacus sed viverra tellus. Potenti nullam ac - tortor vitae. Massa id neque aliquam vestibulum. Ornare arcu odio ut - sem nulla pharetra. Quam id leo in vitae turpis massa. Interdum - velit euismod in pellentesque massa placerat duis ultricies lacus. - Maecenas sed enim ut sem viverra aliquet eget sit amet. Amet - venenatis urna cursus eget nunc scelerisque viverra mauris. Interdum - varius sit amet mattis. Aliquet nec ullamcorper sit amet risus - nullam. Aliquam faucibus purus in massa tempor nec feugiat. Vitae - turpis massa sed elementum tempus. Feugiat in ante metus dictum at - tempor. Malesuada nunc vel risus commodo viverra maecenas accumsan. - Integer vitae justo.`, - }, -}; - -const ProfilePage = () => { - const [editMode, setEditMode] = useState(false); - const [profileFound, setProfileFound] = useState(false); - const [profile, setProfile] = useState(null); - - const state = useGlobalContext(); - const { loggedIn } = state; - - const changeEditMode = () => { - setEditMode(!editMode); - }; - - const { id } = state; - - const fetchProfile = async () => { - const response = await fetch( - `${process.env.REACT_APP_BACKEND_SERVER}/getProfessorProfile/${id}` - ); - - if (response) { - let data = await response.json(); - setProfile(data); - setProfileFound(true); - } else { - setProfileFound(false); - } - }; - - useEffect(() => { - if (id) { - fetchProfile(); - } - }, []); - - var editButton = ( - - ); - - const profilePage = ( -
-
- - -
- -
- ); - - return ( -
-
- {!loggedIn ? ( - "Please log in to view your profile" - ) : profileFound ? ( - <> - {loggedIn && editButton} - {loggedIn && editMode && } - {loggedIn && !editMode && profilePage} - - ) : ( - "Profile not found" - )} -
-
-
-
-
-
-
-
-
- ); -}; - -export default ProfilePage; diff --git a/src/shared/pages/Profile.tsx b/src/shared/pages/Profile.tsx new file mode 100644 index 00000000..51dfa8e5 --- /dev/null +++ b/src/shared/pages/Profile.tsx @@ -0,0 +1,51 @@ +import React, { useEffect } from "react"; +import { useState } from "react"; +import ProfileComponents from "../components/Profile/ProfileComponents.tsx"; +// import EditProfile from "./EditProfile"; + +const ProfilePage = (authenticated) => { + + if (authenticated[0] === false) { + window.location.href = "/login"; + } + + // const [editMode, setEditMode] = useState(false); + const [profile, setProfile] = useState(null); + + // const changeEditMode = () => { + // setEditMode(!editMode); + // }; + + const fetchProfile = async () => { + const response = await fetch( + `${process.env.REACT_APP_BACKEND_SERVER}/profile` + ); + + if (response.ok) { + const data = await response.json(); + setProfile(data); + } else { + setProfile(false); + } + }; + + useEffect(() => { + fetchProfile(); + }, []); + + // const editButton = ( + // + // ); + + return ( + <> + {profile === null && "Loading..."} + {profile && typeof profile === "object" && } + {profile === false && "Profile not found"} + + ); +}; + +export default ProfilePage; From 408aa7080f6d5c8e02dc32278cc906649cb5b85e Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:18:04 -0400 Subject: [PATCH 03/13] Create component to handle profile items Used in Profile Page and Staff Page --- .../components/Profile/ProfileComponents.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/shared/components/Profile/ProfileComponents.tsx diff --git a/src/shared/components/Profile/ProfileComponents.tsx b/src/shared/components/Profile/ProfileComponents.tsx new file mode 100644 index 00000000..42d92147 --- /dev/null +++ b/src/shared/components/Profile/ProfileComponents.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import ProfileAvatar from "./ProfileAvatar.tsx"; +import ProfileDescription from "./ProfileDescription.tsx"; +import ProfileOpportunities from "./ProfileOpportunities.tsx"; + +interface Profile { + name: string; + image: string; + department: string; + description: string; + website?: string; +} + +const ProfileComponents = ({ profile, staffId }: { profile: Profile, staffId?: string }) => { + return ( +
+
+ + +
+ {staffId && } +
+ ); +} + +export default ProfileComponents; From 2fc01bce7deb21af4d44e0bf1dacefd031377456 Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:18:13 -0400 Subject: [PATCH 04/13] Use new profile components --- src/staff/pages/Staff.tsx | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/src/staff/pages/Staff.tsx b/src/staff/pages/Staff.tsx index c777f4ea..9003e59b 100644 --- a/src/staff/pages/Staff.tsx +++ b/src/staff/pages/Staff.tsx @@ -1,12 +1,10 @@ import React, { useState, useEffect } from "react"; -import ProfileAvatar from "../../shared/components/UIElements/ProfileAvatar.tsx"; -import ProfileDescription from "../components/ProfileDescription.tsx"; -import ProfileOpportunities from "../components/ProfileOpportunities.tsx"; +import ProfileComponents from "../../shared/components/Profile/ProfileComponents.tsx"; import { useParams } from "react-router"; const StaffPage = () => { const { staffId } = useParams(); - const [profile, setProfile] = useState<{ name?: string; image?: string; department?: string; description?: string; website?: string } | "not found" | null>(null); + const [profile, setProfile] = useState(null); const checkProfile = (data) => { return data.name && data.image && data.department && data.description; @@ -18,13 +16,13 @@ const StaffPage = () => { ); if (!response.ok) { - setProfile("not found"); + setProfile(false); } else { const data = await response.json(); if (checkProfile(data)) { setProfile(data); } else { - setProfile("not found"); + setProfile(false); console.log(data); } } @@ -34,31 +32,11 @@ const StaffPage = () => { fetchProfile(); }, []); - const profileComponents = ( -
-
- {typeof profile === "object" && profile !== null && ( - - )} - {typeof profile === "object" && profile !== null && ( - - )} -
- {staffId && } -
- ); - return ( <> - {!profile && "Loading..."} - {typeof profile === "object" && profileComponents} - {profile === "not found" && "Profile not found"} + {profile === null && "Loading..."} + {profile && typeof profile === "object" && } + {profile === false && "Profile not found"} ); }; From fab0e2cf61dd3da4b1806311160c50274cb0ab69 Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:18:29 -0400 Subject: [PATCH 05/13] Update App.tsx for new typescript file --- src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index b6788dca..e0fcdabe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,7 +10,7 @@ import StaffPage from "./staff/pages/Staff.tsx"; import Department from "./staff/pages/Department.tsx"; import CreatePost from "./staff/pages/CreatePost.js"; import IndividualPost from "./opportunities/pages/IndividualPost.js"; -import ProfilePage from "./shared/pages/Profile.js"; +import ProfilePage from "./shared/pages/Profile.tsx"; import LoginRedirection from "./auth/Login.tsx"; import LogoutRedirection from "./auth/Logout.tsx"; import { GlobalContextProvider } from "./context/global/GlobalContextProvider.js"; From 2837a81ba346dff2d51c32f591b0eb09388969b6 Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:24:04 -0500 Subject: [PATCH 06/13] clean up auth context use --- src/context/AuthContext.tsx | 11 +++++++---- src/shared/components/Navigation/MainNavigation.tsx | 7 +++++-- src/shared/components/Navigation/StickyFooter.tsx | 7 +++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index add455b5..ab76457f 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -1,4 +1,6 @@ -import React, { createContext, useState, useContext } from 'react'; +import React, { createContext, useState, useContext, useEffect } from 'react'; +import { ReactNode } from 'react'; + const AuthContext = createContext<{ auth: { isAuthenticated: boolean; token: string | null }; @@ -11,9 +13,6 @@ const AuthContext = createContext<{ logout: () => { }, loadToken: () => { } }); - -import { ReactNode } from 'react'; - interface AuthProviderProps { children: ReactNode; } @@ -43,6 +42,10 @@ export const AuthProvider = ({ children }: AuthProviderProps) => { } }; + useEffect(() => { + loadToken(); + }, []); + return ( {children} diff --git a/src/shared/components/Navigation/MainNavigation.tsx b/src/shared/components/Navigation/MainNavigation.tsx index 2bcb4042..62131eea 100644 --- a/src/shared/components/Navigation/MainNavigation.tsx +++ b/src/shared/components/Navigation/MainNavigation.tsx @@ -2,11 +2,14 @@ import React from "react"; import { Disclosure } from "@headlessui/react"; import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline"; import { Link, NavLink, useLocation } from "react-router-dom"; +import { useAuth } from "../../../context/AuthContext.tsx"; -export default function MainNavigation(authenticated) { +export default function MainNavigation() { + + const { auth } = useAuth(); const location = useLocation().pathname; - const routes = authenticated.authenticated[1] + const routes = auth.isAuthenticated ? [ { name: "Jobs", href: "/jobs", current: true }, { name: "Create", href: "/create", current: false }, diff --git a/src/shared/components/Navigation/StickyFooter.tsx b/src/shared/components/Navigation/StickyFooter.tsx index 976a7c12..196bb07d 100644 --- a/src/shared/components/Navigation/StickyFooter.tsx +++ b/src/shared/components/Navigation/StickyFooter.tsx @@ -1,10 +1,13 @@ import React from "react"; import { Link } from "react-router-dom"; import logo from "../../../images/LabConnect_Logo.webp"; +import { useAuth } from "../../../context/AuthContext.tsx"; -export default function StickyFooter(authenticated) { +export default function StickyFooter() { - const routes = authenticated.authenticated[1] + const { auth } = useAuth(); + + const routes = auth.isAuthenticated ? [ { name: "Jobs", href: "/jobs", current: true }, { name: "Create", href: "/create", current: false }, From 9f9bb153c8ea62274dd265952d4878e3170e16af Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:39:15 -0500 Subject: [PATCH 07/13] minor fixes to auth things --- src/auth/Logout.tsx | 2 +- src/auth/Token.tsx | 43 ++++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/auth/Logout.tsx b/src/auth/Logout.tsx index 1d31e828..08b71716 100644 --- a/src/auth/Logout.tsx +++ b/src/auth/Logout.tsx @@ -32,7 +32,7 @@ export default function LogoutRedirection() { } } logoutUser(); - }, [auth, logout]); + }, [logout, auth.token]); return null; // Since this component doesn't need to render anything }; \ No newline at end of file diff --git a/src/auth/Token.tsx b/src/auth/Token.tsx index 515f5d87..411cf617 100644 --- a/src/auth/Token.tsx +++ b/src/auth/Token.tsx @@ -1,4 +1,5 @@ import { useAuth } from "../context/AuthContext.tsx"; +import { useEffect } from "react"; export default function Token() { @@ -7,26 +8,30 @@ export default function Token() { const urlParams = new URLSearchParams(window.location.search); const code = urlParams.get("code"); - if (code) { - fetch(`${process.env.REACT_APP_BACKEND_SERVER}/token`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ code }), - }) - .then((response) => response.json()) - .then((data) => { - const token = data.token; - if (token) { - login(token); - return null; - } + useEffect(() => { + async function fetchToken(code: string) { + fetch(`${process.env.REACT_APP_BACKEND_SERVER}/token`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ code }), }) - .catch((error) => console.error("Error fetching token:", error)); - } else { - window.location.href = "/"; - } + .then((response) => response.json()) + .then((data) => { + const token = data.token; + if (token) { + login(token); + window.location.href = "/"; + return null; + } + }) + .catch((error) => console.error("Error fetching token:", error)); + } + if (code) { + fetchToken(code); + } + }, [code, login]); return null; } \ No newline at end of file From 737aff83dae5b8c722b12a50c2bfc94cf426bc9d Mon Sep 17 00:00:00 2001 From: Rafael Cenzano <32753063+RafaelCenzano@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:41:52 -0500 Subject: [PATCH 08/13] Complete profile page --- src/shared/pages/Profile.tsx | 59 ++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/shared/pages/Profile.tsx b/src/shared/pages/Profile.tsx index 51dfa8e5..5859efaf 100644 --- a/src/shared/pages/Profile.tsx +++ b/src/shared/pages/Profile.tsx @@ -1,37 +1,54 @@ import React, { useEffect } from "react"; import { useState } from "react"; import ProfileComponents from "../components/Profile/ProfileComponents.tsx"; +import { useAuth } from "../../context/AuthContext.tsx"; // import EditProfile from "./EditProfile"; -const ProfilePage = (authenticated) => { +export default function ProfilePage() { + const { auth } = useAuth(); - if (authenticated[0] === false) { + if (!auth.isAuthenticated) { window.location.href = "/login"; } // const [editMode, setEditMode] = useState(false); - const [profile, setProfile] = useState(null); + interface Profile { + id: string; + name: string; + image: string; + department: string; + description: string; + website?: string; + } + + const [profile, setProfile] = useState(null); // const changeEditMode = () => { // setEditMode(!editMode); // }; - const fetchProfile = async () => { - const response = await fetch( - `${process.env.REACT_APP_BACKEND_SERVER}/profile` - ); - - if (response.ok) { - const data = await response.json(); - setProfile(data); - } else { - setProfile(false); - } - }; - useEffect(() => { + const fetchProfile = async () => { + const response = await fetch( + `${process.env.REACT_APP_BACKEND_SERVER}/profile`, { + headers: { + Authorization: `Bearer ${auth.token}`, + }, + } + ); + + if (response.ok) { + const data = await response.json(); + // if (data.lab_manager) { + // window.location.href = "/staff/" + data.id; + // } + setProfile(data); + } else { + setProfile(false); + } + }; fetchProfile(); - }, []); + }, [auth.token]); // const editButton = ( //