Skip to content

Commit cb24fbc

Browse files
committed
#1641: Sorted array by date, rounded tab borders, and utilized fullNamePipe
1 parent 3dc0a4d commit cb24fbc

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useAllChangeRequests } from '../../hooks/change-requests.hooks';
1111
import { ExpandLess, ExpandMore } from '@mui/icons-material';
1212
import LoadingIndicator from '../../components/LoadingIndicator';
1313
import ErrorPage from '../ErrorPage';
14+
import { fullNamePipe } from '../../utils/pipes';
1415

1516
interface OtherChangeRequestsPopupTabsProps {
1617
changeRequest: ChangeRequest;
@@ -27,15 +28,20 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps>
2728
if (isError) return <ErrorPage error={error} message={error.message} />;
2829

2930
// the CRs submitted or reviewed by the submitter of this CR
30-
const crsFromSubmitter = changeRequests?.filter(
31-
(cr) =>
32-
(cr.submitter.userId === changeRequest.submitter.userId || cr.reviewer?.userId === changeRequest.submitter.userId) &&
33-
cr.crId !== changeRequest.crId
34-
);
31+
const crsFromSubmitter = changeRequests
32+
?.filter(
33+
(cr) =>
34+
(cr.submitter.userId === changeRequest.submitter.userId || cr.reviewer?.userId === changeRequest.submitter.userId) &&
35+
cr.crId !== changeRequest.crId
36+
)
37+
.sort((a: ChangeRequest, b: ChangeRequest) => {
38+
return b.dateSubmitted.getTime() - a.dateSubmitted.getTime();
39+
});
3540

3641
const displayTab = (value: number, title: string) => (
3742
<Tab
3843
value={value}
44+
sx={{ borderRadius: '16px 16px 0 0' }}
3945
label={
4046
<Typography sx={{ display: 'flex' }}>
4147
{title}
@@ -107,7 +113,7 @@ const OtherChangeRequestsPopupTabs: React.FC<OtherChangeRequestsPopupTabsProps>
107113
mb: '-1px'
108114
}}
109115
>
110-
{displayTab(1, `Other CR's from ${changeRequest.submitter.firstName} ${changeRequest.submitter.lastName}`)}
116+
{displayTab(1, `Other CR's from ${fullNamePipe(changeRequest.submitter)}`)}
111117
</Tabs>
112118
<Collapse in={tab !== 0}>{tab === 1 && displayCRCards(crsFromSubmitter || [])}</Collapse>
113119
</Box>

0 commit comments

Comments
 (0)