From f3dcfb408f728b1399a9ab7620368a16781efad6 Mon Sep 17 00:00:00 2001 From: danieldeng2 <danieldeng223@gmail.com> Date: Sat, 8 Aug 2020 03:58:42 +0100 Subject: [PATCH] Use separate router switch for leftbar --- .../components/pages/StandardView/index.tsx | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/pages/StandardView/index.tsx b/frontend/src/components/pages/StandardView/index.tsx index f9fb01ee5..dd187bb15 100644 --- a/frontend/src/components/pages/StandardView/index.tsx +++ b/frontend/src/components/pages/StandardView/index.tsx @@ -36,46 +36,58 @@ const StandardView: React.FC<StandardViewProps> = ({ toggledRight: toggledRight, })} > + <Switch> + <Route path="/modules/:id"> + <LeftBarModule /> + </Route> + + <Route exact path="/modules"> + <LeftBarModuleList /> + </Route> + + <Route path="/"> + <LeftBarHome /> + </Route> + </Switch> + <RightBar /> <div id="sidenav-overlay" onClick={(e) => onOverlayClick(e)}></div> + <Switch> <Route path="/home"> - <LeftBarHome /> <ExamplePage name="Home" /> </Route> - <Route exact path="/modules"> - <LeftBarModuleList /> + <Route exact path="/modules"> <ModuleList /> </Route> - <Route path="/modules/:id/overview"> - <LeftBarModule/> + <Route path="/modules/:id/overview"> <ModuleOverview /> </Route> - <Route path="/modules/:id/materials"> - <LeftBarModule/> + <Route path="/modules/:id/materials"> <ModuleMaterials /> </Route> - <Route path="/modules/:id/coursework"> - <LeftBarModule/> + <Route path="/modules/:id/coursework"> <ModuleCoursework /> </Route> - <Route path="/modules/:id" render={props => <Redirect to={`/modules/${props.match.params.id}/overview`} />} /> - - <Route path="/timetable"> - <LeftBarHome /> + <Route path="/timetable"> <ExamplePage name="Timetable" /> </Route> - <Route path="/exams"> - <LeftBarHome /> + <Route path="/exams"> <ExamplePage name="Exams" /> </Route> + <Route + path="/modules/:id" + render={(props) => ( + <Redirect to={`/modules/${props.match.params.id}/overview`} /> + )} + /> <Route path="/" render={() => <Redirect to="/home" />} /> </Switch> </div> -- GitLab