Skip to content

Commit 17510d3

Browse files
committed
#1565: Added an alert for overdue work packages
1 parent ea0cace commit 17510d3

3 files changed

Lines changed: 82 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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { useHistory } from 'react-router-dom';
2+
import { useState, useEffect } from 'react';
3+
import { wbsPipe, WorkPackage } from 'shared';
4+
import { Box, Alert, IconButton, Collapse, Link, Typography, AlertTitle, Card } from '@mui/material';
5+
import CloseIcon from '@mui/icons-material/Close';
6+
import { routes } from '../../utils/routes';
7+
import { Link as RouterLink } from 'react-router-dom';
8+
import { datePipe } from '../../utils/pipes';
9+
import { NERButton } from '../../components/NERButton';
10+
11+
const OverdueWorkPackageAlert = ({ wp }: { wp: WorkPackage }) => {
12+
const history = useHistory();
13+
const [open, setOpen] = useState(true);
14+
15+
return (
16+
<Box sx={{ width: '100%', my: 2 }}>
17+
<Collapse in={open}>
18+
<Alert
19+
variant="filled"
20+
severity="warning"
21+
action={
22+
<IconButton
23+
aria-label="close"
24+
color="inherit"
25+
size="small"
26+
onClick={() => {
27+
setOpen(false);
28+
}}
29+
>
30+
<CloseIcon fontSize="inherit" />
31+
</IconButton>
32+
}
33+
>
34+
<AlertTitle>Overdue Work Package:</AlertTitle>
35+
<Link color="inherit" component={RouterLink} to={`${routes.PROJECTS}/${wbsPipe(wp.wbsNum)}`} noWrap>
36+
<Typography fontWeight={'regular'} variant="inherit">
37+
{wbsPipe(wp.wbsNum)} - {wp.name}
38+
</Typography>
39+
</Link>
40+
<Typography fontWeight={'regular'} variant="inherit" noWrap my={0.5}>
41+
{'Due: ' + datePipe(wp.endDate)}
42+
</Typography>
43+
<NERButton
44+
variant="contained"
45+
size="small"
46+
onClick={() => history.push(`${routes.PROJECTS}/${wbsPipe(wp.wbsNum)}`)}
47+
>
48+
Create Change Request
49+
</NERButton>
50+
</Alert>
51+
</Collapse>
52+
</Box>
53+
);
54+
};
55+
56+
export default OverdueWorkPackageAlert;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Box from '@mui/material/Box';
2+
import { useAllWorkPackages } from '../../hooks/work-packages.hooks';
3+
import { WbsElementStatus } from 'shared';
4+
import OverdueWorkPackageAlert from './OverdueWorkPackageAlert';
5+
import { useCurrentUser } from '../../hooks/users.hooks';
6+
7+
const OverdueWorkPackageAlerts: React.FC = () => {
8+
const user = useCurrentUser();
9+
const workPackages = useAllWorkPackages({ status: WbsElementStatus.Active });
10+
const currentDate = new Date();
11+
12+
return (
13+
<Box>
14+
{workPackages.data
15+
?.filter((wp) => wp.projectLead?.userId === user.userId)
16+
?.filter((wp) => new Date(wp.endDate) < currentDate)
17+
.map((wp) => (
18+
<OverdueWorkPackageAlert wp={wp} />
19+
))}
20+
</Box>
21+
);
22+
};
23+
24+
export default OverdueWorkPackageAlerts;

0 commit comments

Comments
 (0)