From a96e0966ea0277b99ec011729812a00a58a8ae3e Mon Sep 17 00:00:00 2001 From: Dylan McReynolds Date: Wed, 23 Aug 2023 11:00:53 -0700 Subject: [PATCH] rebase fix --- web-frontend/src/App.tsx | 76 ++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/web-frontend/src/App.tsx b/web-frontend/src/App.tsx index ad30c3607..2043bbea7 100644 --- a/web-frontend/src/App.tsx +++ b/web-frontend/src/App.tsx @@ -2,6 +2,7 @@ import React from 'react'; import {AxiosInterceptor} from './client'; import Container from "@mui/material/Container"; import ErrorBoundary from "./components/error-boundary"; +import Login from "./routes/login"; import { Outlet } from "react-router-dom"; import TiledAppBar from "./components/tiled-app-bar"; import { useEffect, useState } from "react"; @@ -10,10 +11,8 @@ import { SettingsContext, emptySettings } from "./context/settings" import { BrowserRouter, Route, Routes } from "react-router-dom"; import { Suspense, lazy } from "react"; import Skeleton from "@mui/material/Skeleton"; - -const Browse = lazy(() => import("./routes/browse")); import UserContext, {userObjectContext} from './context/user'; - +const Browse = lazy(() => import("./routes/browse")); function MainContainer() { @@ -27,31 +26,28 @@ function MainContainer() { ) } -// attempt to do user contextg for authentication -const [userContext, setUserContext] = React.useState(userObjectContext) -// Create funtion to update the current context, prioritizing new over old changed properties -const updateContext = (contextUpdates = {}) => - setUserContext(currentContext => ({ ...currentContext, ...contextUpdates })) +// This is set in vite.config.js. It is the base path of the ui. +const basename = import.meta.env.BASE_URL; -// useEffect prevents the entire context for rerendering when component rerenders -React.useEffect(() => { - if (userContext?.updateUser === userUpdateFunctionTemplate) { - updateContext({ - - updateStatus: (value: string) => updateContext({ status: value }), - }) - } -}, [userContext?.updateUser]) +function App() { + const [userContext, setUserContext] = React.useState(userObjectContext) + const [user, setUser] = React.useState({user: ""}); + const value = { user, setUser }; + // Create function to update the current context, prioritizing new over old changed properties + const updateContext = (contextUpdates = {}) => + setUserContext(currentContext => ({ ...currentContext, ...contextUpdates })) -// end authentication + // useEffect prevents the entire context for rerendering when component rerenders + React.useEffect(() => { + updateContext({ + updateStatus: (value: string) => updateContext({ user: value }), + }) + + }, []) -// This is set in vite.config.js. It is the base path of the ui. -const basename = import.meta.env.BASE_URL; -function App() { - const [settings, setSettings] = useState(emptySettings) useEffect( () => { const controller = new AbortController() @@ -62,26 +58,16 @@ function App() { initSettingsContext() } , []); return ( - - {/* */} - - - - - - - {/* */} - - ); - - - - - }> + + + + }> + }> } /> + } /> - - - - - - + + + + + + ) } -export default App; +export default App; \ No newline at end of file