Skip to content

Commit 3a5b06a

Browse files
authored
Merge pull request #1652 from Northeastern-Electric-Racing/#1565-late-WP-reminder-popup
#1565 late wp reminder popup
2 parents 9342980 + 83072a4 commit 3a5b06a

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

src/frontend/src/pages/HomePage/Home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { Typography, Alert, Link } from '@mui/material';
77
import { routes } from '../../utils/routes';
8+
import OverdueWorkPackageAlerts from './OverdueWorkPackageAlerts';
89
import UsefulLinks from './UsefulLinks';
910
import WorkPackagesByTimelineStatus from './WorkPackagesByTimelineStatus';
1011
import UpcomingDeadlines from './UpcomingDeadlines';
@@ -36,6 +37,7 @@ const Home = () => {
3637
.
3738
</Alert>
3839
)}
40+
<OverdueWorkPackageAlerts />
3941
<UsefulLinks />
4042
<UpcomingDeadlines />
4143
<WorkPackagesByTimelineStatus />
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React from 'react';
2+
import { useAllWorkPackages } from '../../hooks/work-packages.hooks';
3+
import { WbsElementStatus } from 'shared';
4+
import { useCurrentUser } from '../../hooks/users.hooks';
5+
import { wbsPipe } from 'shared';
6+
import { Box, Alert, Typography, AlertTitle, Grid } from '@mui/material';
7+
import { routes } from '../../utils/routes';
8+
import { datePipe } from '../../utils/pipes';
9+
import { NERButton } from '../../components/NERButton';
10+
import { useHistory } from 'react-router-dom';
11+
12+
const OverdueWorkPackageAlerts: React.FC = () => {
13+
const user = useCurrentUser();
14+
const workPackages = useAllWorkPackages({ status: WbsElementStatus.Active });
15+
const currentDate = new Date();
16+
const history = useHistory();
17+
18+
// Filter for work packages that are overdue and the user is the project lead
19+
const userOverdueWorkPackages = workPackages.data
20+
?.filter((wp) => wp.projectLead?.userId === user.userId)
21+
?.filter((wp) => new Date(wp.endDate) < currentDate);
22+
23+
// If there are no overdue work packages, don't display anything
24+
if (!userOverdueWorkPackages || userOverdueWorkPackages.length === 0) {
25+
return null;
26+
} else {
27+
return (
28+
<Box sx={{ width: '100%', my: 2 }}>
29+
<Alert
30+
variant="filled"
31+
severity="warning"
32+
sx={{
33+
'& .MuiAlert-message': {
34+
width: '100%'
35+
}
36+
}}
37+
>
38+
<Box>
39+
<AlertTitle>
40+
{userOverdueWorkPackages.length > 1 ? 'Overdue Work Packages:' : 'Overdue Work Package:'}
41+
</AlertTitle>
42+
<Grid container spacing={2}>
43+
{userOverdueWorkPackages.map((wp) => (
44+
<Grid item xs={6} md={3} key={wp.id}>
45+
{wbsPipe(wp.wbsNum)} - {wp.name}
46+
<Typography fontWeight={'regular'} variant="inherit" noWrap my={0.5}>
47+
{'Due: ' + datePipe(wp.endDate)}
48+
</Typography>
49+
<NERButton
50+
variant="contained"
51+
size="small"
52+
onClick={() => history.push(`${routes.PROJECTS}/${wbsPipe(wp.wbsNum)}`)}
53+
>
54+
Create Change Request
55+
</NERButton>
56+
</Grid>
57+
))}
58+
</Grid>
59+
</Box>
60+
</Alert>
61+
</Box>
62+
);
63+
}
64+
};
65+
66+
export default OverdueWorkPackageAlerts;

0 commit comments

Comments
 (0)