Skip to content

Commit 29d5942

Browse files
authored
Merge pull request #1737 from Northeastern-Electric-Racing/#1642-cr-popup-same-wbs
#1642 cr popup same wbs
2 parents ce061d4 + a01d54a commit 29d5942

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

src/frontend/src/pages/ChangeRequestDetailPage/OtherChangeRequestsPopupTabs.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
import React, { useState } from 'react';
77
import { Box, useTheme, Collapse, Tabs, Tab, Typography } from '@mui/material';
8-
import { ChangeRequest } from 'shared';
8+
import { ChangeRequest, wbsPipe } from 'shared';
99
import ChangeRequestDetailCard from '../../components/ChangeRequestDetailCard';
1010
import { useAllChangeRequests } from '../../hooks/change-requests.hooks';
11-
import { ExpandLess, ExpandMore } from '@mui/icons-material';
1211
import LoadingIndicator from '../../components/LoadingIndicator';
1312
import ErrorPage from '../ErrorPage';
1413
import { fullNamePipe } from '../../utils/pipes';
@@ -38,18 +37,14 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps>
3837
return b.dateSubmitted.getTime() - a.dateSubmitted.getTime();
3938
});
4039

40+
const crsFromWbs = changeRequests
41+
?.filter((cr) => cr.wbsName === changeRequest.wbsName)
42+
.sort((a: ChangeRequest, b: ChangeRequest) => {
43+
return b.dateSubmitted.getTime() - a.dateSubmitted.getTime();
44+
});
45+
4146
const displayTab = (value: number, title: string) => (
42-
<Tab
43-
value={value}
44-
sx={{ borderRadius: '16px 16px 0 0' }}
45-
label={
46-
<Typography sx={{ display: 'flex' }}>
47-
{title}
48-
{tab === value ? <ExpandMore sx={{ pl: 0.5 }} /> : <ExpandLess sx={{ pl: 0.5 }} />}
49-
</Typography>
50-
}
51-
onClick={() => tab === value && setTab(0)}
52-
/>
47+
<Tab value={value} sx={{ borderRadius: '16px 16px 0 0' }} label={title} onClick={() => tab === value && setTab(0)} />
5348
);
5449

5550
const displayCRCards = (crList: ChangeRequest[]) => (
@@ -113,9 +108,12 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps>
113108
mb: '-1px'
114109
}}
115110
>
116-
{displayTab(1, `Other CR's from ${fullNamePipe(changeRequest.submitter)}`)}
111+
{displayTab(1, `Other CR's on ${wbsPipe(changeRequest.wbsNum)}`)}
112+
{displayTab(2, `Other CR's from ${fullNamePipe(changeRequest.submitter)}`)}
117113
</Tabs>
118-
<Collapse in={tab !== 0}>{tab === 1 && displayCRCards(crsFromSubmitter || [])}</Collapse>
114+
<Collapse in={tab !== 0}>
115+
{tab === 1 ? displayCRCards(crsFromWbs || []) : tab === 2 && displayCRCards(crsFromSubmitter || [])}
116+
</Collapse>
119117
</Box>
120118
);
121119
};

0 commit comments

Comments
 (0)