@@ -21,90 +21,23 @@ import LoadingIndicator from '../components/LoadingIndicator';
2121import SessionTimeoutAlert from './SessionTimeoutAlert' ;
2222import SetUserPreferences from '../pages/HomePage/components/SetUserPreferences' ;
2323import Finance from '../pages/FinancePage/Finance' ;
24- import Sidebar from '../layouts/Sidebar/Sidebar' ;
25- import { Box } from '@mui/system' ;
26- import { Container , IconButton , useTheme } from '@mui/material' ;
2724import ErrorPage from '../pages/ErrorPage' ;
2825import { Role , isGuest } from 'shared' ;
29- import { useState } from 'react' ;
30- import ArrowCircleRightTwoToneIcon from '@mui/icons-material/ArrowCircleRightTwoTone' ;
31- import HiddenContentMargin from '../components/HiddenContentMargin' ;
32- import { useHomePageContext } from './HomePageContext' ;
3326import { useCurrentOrganization } from '../hooks/organizations.hooks' ;
3427import Statistics from '../pages/StatisticsPage/Statistics' ;
3528import RetrospectiveGanttChartPage from '../pages/RetrospectivePage/Retrospective' ;
3629import Calendar from '../pages/CalendarPage/Calendar' ;
3730import GuestEventPage from '../pages/GuestEventPage/GuestEventPage' ;
31+ import SidebarLayout from '../layouts/SidebarLayout' ;
3832
3933interface AppAuthenticatedProps {
4034 userId : string ;
4135 userRole : Role ;
4236}
4337
44- const SidebarLayout : React . FC < { children : React . ReactNode } > = ( { children } ) => {
45- const theme = useTheme ( ) ;
46- const [ drawerOpen , setDrawerOpen ] = useState ( false ) ;
47- const [ moveContent , setMoveContent ] = useState ( false ) ;
48- const { onGuestHomePage } = useHomePageContext ( ) ;
49-
50- return (
51- < >
52- < Box
53- onMouseEnter = { ( ) => {
54- setDrawerOpen ( true ) ;
55- } }
56- sx = { {
57- height : '100vh' ,
58- position : 'fixed' ,
59- width : 15 ,
60- borderRight : 2 ,
61- borderRightColor : theme . palette . background . paper
62- } }
63- />
64- < IconButton
65- onClick = { ( ) => {
66- setDrawerOpen ( true ) ;
67- setMoveContent ( true ) ;
68- } }
69- sx = { { position : 'fixed' , left : - 8 , top : '3%' } }
70- id = "sidebar-button"
71- >
72- < ArrowCircleRightTwoToneIcon
73- sx = { {
74- fontSize : '30px' ,
75- zIndex : 1 ,
76- '& path:first-of-type' : { color : '#000000' } ,
77- '& path:last-of-type' : { color : '#ef4345' }
78- } }
79- />
80- </ IconButton >
81- < Sidebar
82- drawerOpen = { drawerOpen }
83- setDrawerOpen = { setDrawerOpen }
84- moveContent = { moveContent }
85- setMoveContent = { setMoveContent }
86- />
87- < Box display = { 'flex' } >
88- < HiddenContentMargin open = { moveContent } variant = "permanent" />
89- < Container
90- maxWidth = { false }
91- sx = { { width : onGuestHomePage && moveContent ? 'calc(100vw - 220px)' : `calc(100vw - 30px)` } }
92- >
93- { children }
94- </ Container >
95- </ Box >
96- </ >
97- ) ;
98- } ;
99-
10038const AppAuthenticated : React . FC < AppAuthenticatedProps > = ( { userId, userRole } ) => {
10139 const { isLoading, isError, error, data : userSettingsData } = useSingleUserSettings ( userId ) ;
10240
103- const theme = useTheme ( ) ;
104- const [ drawerOpen , setDrawerOpen ] = useState ( false ) ;
105- const [ moveContent , setMoveContent ] = useState ( false ) ;
106- const { onGuestHomePage } = useHomePageContext ( ) ;
107-
10841 const {
10942 data : organization ,
11043 isLoading : organizationIsLoading ,
@@ -127,72 +60,27 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
12760
12861 return userSettingsData . slackId || isGuest ( userRole ) ? (
12962 < AppContextUser >
130- {
131- < >
132- < Box
133- onMouseEnter = { ( ) => {
134- setDrawerOpen ( true ) ;
135- } }
136- sx = { {
137- height : '100vh' ,
138- position : 'fixed' ,
139- width : 15 ,
140- borderRight : 2 ,
141- borderRightColor : theme . palette . background . paper
142- } }
143- />
144- < IconButton
145- onClick = { ( ) => {
146- setDrawerOpen ( true ) ;
147- setMoveContent ( true ) ;
148- } }
149- sx = { { position : 'fixed' , left : - 8 , top : '3%' } }
150- id = "sidebar-button"
151- >
152- < ArrowCircleRightTwoToneIcon
153- sx = { {
154- fontSize : '30px' ,
155- zIndex : 1 ,
156- '& path:first-of-type' : { color : '#000000' } ,
157- '& path:last-of-type' : { color : '#ef4345' }
158- } }
159- />
160- </ IconButton >
161- < Sidebar
162- drawerOpen = { drawerOpen }
163- setDrawerOpen = { setDrawerOpen }
164- moveContent = { moveContent }
165- setMoveContent = { setMoveContent }
166- />
167- </ >
168- }
169- < Box display = { 'flex' } >
170- < HiddenContentMargin open = { moveContent } variant = "permanent" />
171- < Container
172- maxWidth = { false }
173- sx = { { width : onGuestHomePage && moveContent ? 'calc(100vw - 220px)' : `calc(100vw - 30px)` } }
174- >
175- < Switch >
176- < Route path = { routes . PROJECTS } component = { Projects } />
177- < Redirect from = { routes . CR_BY_ID } to = { routes . CHANGE_REQUESTS_BY_ID } />
178- < Route path = { routes . CHANGE_REQUESTS } component = { ChangeRequests } />
179- < Route path = { routes . GANTT } component = { GanttChartPage } />
180- < Route path = { routes . TEAMS } component = { Teams } />
181- < Route path = { routes . SETTINGS } component = { Settings } />
182- < Route path = { routes . ADMIN_TOOLS } component = { AdminTools } />
183- < Route path = { routes . INFO } component = { InfoPage } />
184- < Route path = { routes . CREDITS } component = { Credits } />
185- < Route path = { routes . FINANCE } component = { Finance } />
186- < Route path = { routes . CALENDAR } component = { Calendar } />
187- < Route path = { routes . STATISTICS } component = { Statistics } />
188- < Route path = { routes . HOME } component = { Home } />
189- < Route path = { routes . RETROSPECTIVE } component = { RetrospectiveGanttChartPage } />
190- < Route path = { routes . EVENTS } component = { GuestEventPage } />
191- < Redirect from = { routes . BASE } to = { routes . HOME } />
192- < Route path = "*" component = { PageNotFound } />
193- </ Switch >
194- </ Container >
195- </ Box >
63+ < SidebarLayout >
64+ < Switch >
65+ < Route path = { routes . PROJECTS } component = { Projects } />
66+ < Redirect from = { routes . CR_BY_ID } to = { routes . CHANGE_REQUESTS_BY_ID } />
67+ < Route path = { routes . CHANGE_REQUESTS } component = { ChangeRequests } />
68+ < Route path = { routes . GANTT } component = { GanttChartPage } />
69+ < Route path = { routes . TEAMS } component = { Teams } />
70+ < Route path = { routes . SETTINGS } component = { Settings } />
71+ < Route path = { routes . ADMIN_TOOLS } component = { AdminTools } />
72+ < Route path = { routes . INFO } component = { InfoPage } />
73+ < Route path = { routes . CREDITS } component = { Credits } />
74+ < Route path = { routes . FINANCE } component = { Finance } />
75+ < Route path = { routes . CALENDAR } component = { Calendar } />
76+ < Route path = { routes . STATISTICS } component = { Statistics } />
77+ < Route path = { routes . HOME } component = { Home } />
78+ < Route path = { routes . RETROSPECTIVE } component = { RetrospectiveGanttChartPage } />
79+ < Route path = { routes . EVENTS } component = { GuestEventPage } />
80+ < Redirect from = { routes . BASE } to = { routes . HOME } />
81+ < Route path = "*" component = { PageNotFound } />
82+ </ Switch >
83+ </ SidebarLayout >
19684 </ AppContextUser >
19785 ) : (
19886 < SetUserPreferences userSettings = { userSettingsData } />
0 commit comments