From 7c9345f41d9c86142019cce05ca0495408b01730 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 28 Aug 2023 10:55:50 -0400 Subject: feat: skeleton of app --- src/App.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 19 deletions(-) (limited to 'src/App.js') diff --git a/src/App.js b/src/App.js index 3784575..9d9ee58 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,80 @@ -import logo from './logo.svg'; import './App.css'; +import { RouterProvider, createBrowserRouter, Navigate } from 'react-router-dom'; +import Login from './pages/Login'; +import Surveys from './pages/Surveys'; +import NewSurvey from './pages/NewSurvey'; +import SurveyResults from './pages/SurveyResults'; +import SurveyAssignees from './pages/SurveyAssignees'; +import Users from './pages/Users'; +import NavBar from './components/NavBar'; +import useLoginState from './hooks/useLoginState'; +import CssBaseline from '@mui/material/CssBaseline'; +import CustomThemeProvider from './CustomThemeProvider'; -function App() { +function routes({ login, logout, isLoggedIn }) { + + function withNavBar(component) { + const navbarLinks = [ + { label: 'Surveys', link: '/surveys' }, + { label: 'New Survey', link: '/surveys/new' }, + { label: 'Users', link: '/users' }, + ]; + return (<> + + {component} + ); + } + + if (!isLoggedIn) { + return ([ + { + path: '*', + element: , + }, + ]); + } else { + return ([ + { + path: '/', + element: , + }, + { + path: '/surveys', + element: withNavBar(), + }, + { + path: '/surveys/new', + element: withNavBar(), + }, + { + path: '/surveys/:surveyId/results', + element: withNavBar(), + }, + { + path: '/surveys/:surveyId/assignees', + element: withNavBar(), + }, + { + path: '/users', + element: withNavBar(), + }, + ]); + } + +} + +export default function App() { + const { login, logout, isLoggedIn } = useLoginState(); + const currentRoutes = routes({isLoggedIn, logout, login}); return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
+ <> + + + + + ); } -export default App; -- cgit v1.2.3