From 247895245c25105d5da5028e413736da0e85e1ed Mon Sep 17 00:00:00 2001 From: mxc-maggiechen Date: Tue, 23 Jul 2024 21:09:00 -0400 Subject: [PATCH 1/2] fix --- frontend/src/App.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1bfe4ceb..61dcbc4c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,11 @@ import "bootstrap/dist/css/bootstrap.min.css"; import React, { useState, useReducer, useEffect } from "react"; -import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; +import { + BrowserRouter as Router, + Route, + Switch, + Redirect, +} from "react-router-dom"; import Welcome from "./components/pages/Welcome"; import Login from "./components/auth/Login"; @@ -69,7 +74,17 @@ const App = (): React.ReactElement => { > - + { + return authenticatedUser ? ( + + ) : ( + + ); + }} + /> From cc92fb3b823f207f5bb7936dc35747ac820618d6 Mon Sep 17 00:00:00 2001 From: Carolyn Zhang Date: Thu, 1 Aug 2024 21:37:49 -0400 Subject: [PATCH 2/2] Move welcome redirect into component --- frontend/src/App.tsx | 19 ++----------------- frontend/src/components/pages/Welcome.tsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 61dcbc4c..1bfe4ceb 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,11 +1,6 @@ import "bootstrap/dist/css/bootstrap.min.css"; import React, { useState, useReducer, useEffect } from "react"; -import { - BrowserRouter as Router, - Route, - Switch, - Redirect, -} from "react-router-dom"; +import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import Welcome from "./components/pages/Welcome"; import Login from "./components/auth/Login"; @@ -74,17 +69,7 @@ const App = (): React.ReactElement => { > - { - return authenticatedUser ? ( - - ) : ( - - ); - }} - /> + diff --git a/frontend/src/components/pages/Welcome.tsx b/frontend/src/components/pages/Welcome.tsx index 282f564d..8378d3d0 100644 --- a/frontend/src/components/pages/Welcome.tsx +++ b/frontend/src/components/pages/Welcome.tsx @@ -1,9 +1,16 @@ -import React from "react"; -import { useHistory } from "react-router-dom"; +import React, { useContext } from "react"; +import { Redirect, useHistory } from "react-router-dom"; +import { HOME_PAGE } from "../../constants/Routes"; +import AuthContext from "../../contexts/AuthContext"; const Welcome = (): React.ReactElement => { + const { authenticatedUser } = useContext(AuthContext); const history = useHistory(); + if (authenticatedUser) { + return ; + } + const handleButtonClick = (selectedRole: string) => { history.push(`/login?role=${selectedRole}`); };