diff --git a/sports-matcher/client/src/Layout.js b/sports-matcher/client/src/Layout.js
index 9864c39..4ebcfb9 100644
--- a/sports-matcher/client/src/Layout.js
+++ b/sports-matcher/client/src/Layout.js
@@ -1,6 +1,6 @@
import "./styles/Layout.css";
import "./styles/extra.css";
-import { useEffect, useState } from "react";
+import { useContext } from "react";
import { NavLink, Route, Routes, useNavigate } from "react-router-dom";
import Welcome from "./pages/Welcome";
import Navbar from "react-bootstrap/Navbar";
@@ -9,30 +9,14 @@ import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
import Dashboard from "./pages/Dashboard";
import Login from "./pages/Login";
-import { apiClient } from "./utils/httpClients";
import { globalContext } from "./context.js";
export default function layout() {
const navigate = useNavigate();
- const [state, setState] = useState({
- user: null,
- });
- useEffect(async () => {
- await updateAuthStatus();
- });
-
- async function updateAuthStatus() {
- const getUserResponse = await apiClient.get("/user");
- if (getUserResponse !== 200) {
- setState({ user: null });
- } else {
- setState({ user: getUserResponse.data });
- }
- }
-
- let indentityDisplay = (
+ const context = useContext(globalContext);
+ let identityDisplay = (
);
- if (state.user) {
- indentityDisplay = (
+ if (context.user) {
+ identityDisplay = (