|
5 | 5 |
|
6 | 6 | import React, { useState } from 'react'; |
7 | 7 | import { Box, useTheme, Collapse, Tabs, Tab, Typography } from '@mui/material'; |
8 | | -import { ChangeRequest } from 'shared'; |
| 8 | +import { ChangeRequest, wbsPipe } from 'shared'; |
9 | 9 | import ChangeRequestDetailCard from '../../components/ChangeRequestDetailCard'; |
10 | 10 | import { useAllChangeRequests } from '../../hooks/change-requests.hooks'; |
11 | | -import { ExpandLess, ExpandMore } from '@mui/icons-material'; |
12 | 11 | import LoadingIndicator from '../../components/LoadingIndicator'; |
13 | 12 | import ErrorPage from '../ErrorPage'; |
14 | 13 | import { fullNamePipe } from '../../utils/pipes'; |
@@ -38,18 +37,14 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps> |
38 | 37 | return b.dateSubmitted.getTime() - a.dateSubmitted.getTime(); |
39 | 38 | }); |
40 | 39 |
|
| 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 | + |
41 | 46 | 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)} /> |
53 | 48 | ); |
54 | 49 |
|
55 | 50 | const displayCRCards = (crList: ChangeRequest[]) => ( |
@@ -113,9 +108,12 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps> |
113 | 108 | mb: '-1px' |
114 | 109 | }} |
115 | 110 | > |
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)}`)} |
117 | 113 | </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> |
119 | 117 | </Box> |
120 | 118 | ); |
121 | 119 | }; |
|
0 commit comments