Skip to content

Commit 3d74c61

Browse files
authored
Merge pull request #3955 from Northeastern-Electric-Racing/#3872-RichardFeng-Sidebar
#3872 richard feng sidebar
2 parents 7bb8a6e + 48667ad commit 3d74c61

3 files changed

Lines changed: 84 additions & 32 deletions

File tree

src/backend/src/prisma/seed.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,21 +369,15 @@ const performSeed: () => Promise<void> = async () => {
369369
const mechanical = await TeamsService.createTeamType(
370370
batman,
371371
'Mechanical',
372-
'YouTubeIcon',
372+
'Construction',
373373
'This is the mechanical team',
374374
ner
375375
);
376-
const software = await TeamsService.createTeamType(
377-
thomasEmrax,
378-
'Software',
379-
'InstagramIcon',
380-
'This is the software team',
381-
ner
382-
);
376+
const software = await TeamsService.createTeamType(thomasEmrax, 'Software', 'Code', 'This is the software team', ner);
383377
const electrical = await TeamsService.createTeamType(
384378
cyborg,
385379
'Electrical',
386-
'SettingsIcon',
380+
'ElectricBolt',
387381
'This is the electrical team',
388382
ner
389383
);

src/frontend/src/app/AppAuthenticated.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
7070

7171
return userSettingsData.slackId || isGuest(userRole) ? (
7272
<AppContextUser>
73-
{!onGuestHomePage && (
73+
{
7474
<>
7575
<Box
7676
onMouseEnter={() => {
@@ -108,12 +108,12 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
108108
setMoveContent={setMoveContent}
109109
/>
110110
</>
111-
)}
111+
}
112112
<Box display={'flex'}>
113-
<HiddenContentMargin open={!onGuestHomePage && moveContent} variant="permanent" />
113+
<HiddenContentMargin open={moveContent} variant="permanent" />
114114
<Container
115115
maxWidth={false}
116-
sx={{ width: !onGuestHomePage && moveContent ? 'calc(100vw - 220px)' : `calc(100vw - 30px)` }}
116+
sx={{ width: onGuestHomePage && moveContent ? 'calc(100vw - 220px)' : `calc(100vw - 30px)` }}
117117
>
118118
<Switch>
119119
<Route path={routes.PROJECTS} component={Projects} />

src/frontend/src/layouts/Sidebar/Sidebar.tsx

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import styles from '../../stylesheets/layouts/sidebar/sidebar.module.css';
99
import { Typography, Box, IconButton, Divider } from '@mui/material';
1010
import HomeIcon from '@mui/icons-material/Home';
1111
import AlignHorizontalLeftIcon from '@mui/icons-material/AlignHorizontalLeft';
12+
import RateReviewIcon from '@mui/icons-material/RateReview';
13+
import DashboardIcon from '@mui/icons-material/Dashboard';
14+
import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism';
1215
import FolderIcon from '@mui/icons-material/Folder';
1316
import SyncAltIcon from '@mui/icons-material/SyncAlt';
1417
import GroupIcon from '@mui/icons-material/Group';
@@ -21,7 +24,10 @@ import NavUserMenu from '../PageTitle/NavUserMenu';
2124
import DrawerHeader from '../../components/DrawerHeader';
2225
import { Cached, ChevronLeft, ChevronRight } from '@mui/icons-material';
2326
import { useHomePageContext } from '../../app/HomePageContext';
24-
import { isGuest } from 'shared';
27+
import { isGuest, TeamType } from 'shared';
28+
import * as MuiIcons from '@mui/icons-material';
29+
import { useAllTeamTypes } from '../../hooks/team-types.hooks';
30+
import ErrorPage from '../../pages/ErrorPage';
2531
import BarChartIcon from '@mui/icons-material/BarChart';
2632
import { useCurrentUser } from '../../hooks/users.hooks';
2733
import QueryStatsIcon from '@mui/icons-material/QueryStats';
@@ -40,29 +46,69 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
4046
const [openSubmenu, setOpenSubmenu] = useState<string | null>(null);
4147
const { onPNMHomePage, onOnboardingHomePage } = useHomePageContext();
4248
const user = useCurrentUser();
49+
const { onGuestHomePage } = useHomePageContext();
50+
const { isError: teamsError, error: teamsErrorMsg, data: teams } = useAllTeamTypes();
4351

52+
const allTeams: LinkItem[] = (teams ?? []).map((team: TeamType) => {
53+
const IconComponent = MuiIcons[(team.iconName in MuiIcons ? team.iconName : 'Circle') as keyof typeof MuiIcons];
54+
return {
55+
name: team.name,
56+
icon: <IconComponent />,
57+
route: routes.TEAMS + '/' + team.teamTypeId
58+
};
59+
});
60+
61+
if (teamsError) return <ErrorPage error={teamsErrorMsg} />;
4462
const memberLinkItems: LinkItem[] = [
4563
{
4664
name: 'Home',
4765
icon: <HomeIcon />,
48-
route: routes.HOME
66+
route: onGuestHomePage ? routes.HOME_GUEST : routes.HOME
4967
},
50-
{
68+
!onGuestHomePage && {
5169
name: 'Gantt',
5270
icon: <AlignHorizontalLeftIcon />,
5371
route: routes.GANTT
5472
},
55-
{
56-
name: 'Projects',
57-
icon: <FolderIcon />,
58-
route: routes.PROJECTS
59-
},
60-
{
73+
!onGuestHomePage
74+
? {
75+
name: 'Projects',
76+
icon: <FolderIcon />,
77+
route: routes.PROJECTS
78+
}
79+
: {
80+
name: 'Project Management',
81+
icon: <DashboardIcon />,
82+
route: routes.PROJECTS,
83+
subItems: [
84+
{
85+
name: 'Gantt',
86+
icon: <AlignHorizontalLeftIcon />,
87+
route: routes.GANTT
88+
},
89+
{
90+
name: 'Projects',
91+
icon: <FolderIcon />,
92+
route: routes.PROJECTS
93+
},
94+
{
95+
name: 'Change Requests',
96+
icon: <SyncAltIcon />,
97+
route: routes.CHANGE_REQUESTS
98+
},
99+
{
100+
name: 'Design Review',
101+
icon: <RateReviewIcon />,
102+
route: routes.CALENDAR
103+
}
104+
]
105+
},
106+
!onGuestHomePage && {
61107
name: 'Change Requests',
62108
icon: <SyncAltIcon />,
63109
route: routes.CHANGE_REQUESTS
64110
},
65-
{
111+
!onGuestHomePage && {
66112
name: 'Finance',
67113
icon: <AttachMoneyIcon />,
68114
route: routes.FINANCE,
@@ -84,29 +130,41 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
84130
}
85131
]
86132
},
87-
{
88-
name: 'Teams',
89-
icon: <GroupIcon />,
90-
route: routes.TEAMS
91-
},
92-
{
133+
!onGuestHomePage
134+
? {
135+
name: 'Teams',
136+
icon: <GroupIcon />,
137+
route: routes.TEAMS
138+
}
139+
: {
140+
name: 'Divisions',
141+
icon: <GroupIcon />,
142+
route: routes.TEAMS,
143+
subItems: allTeams
144+
},
145+
!onGuestHomePage && {
93146
name: 'Calendar',
94147
icon: <CalendarTodayIcon />,
95148
route: routes.CALENDAR
96149
},
97-
{
150+
!onGuestHomePage && {
98151
name: 'Retrospective',
99152
icon: <Cached />,
100153
route: routes.RETROSPECTIVE
101154
},
155+
onGuestHomePage && {
156+
name: 'Sponsors',
157+
icon: <VolunteerActivismIcon />,
158+
route: routes.RETROSPECTIVE
159+
},
102160
{
103161
name: 'Info',
104162
icon: <QuestionMarkIcon />,
105163
route: routes.INFO
106164
}
107-
];
165+
].filter(Boolean) as LinkItem[];
108166

109-
if (!isGuest(user.role)) {
167+
if (!isGuest(user.role) && !onGuestHomePage) {
110168
memberLinkItems.splice(6, 0, {
111169
name: 'Statistics',
112170
icon: <BarChartIcon />,

0 commit comments

Comments
 (0)