-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove parentheses if studyAbbr is empty
- Loading branch information
Showing
4 changed files
with
106 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { ElementType, FC } from 'react'; | ||
import { Typography, styled } from '@mui/material'; | ||
import Tooltip from '../Tooltip'; | ||
import { formatFullStudyName } from '../../utils'; | ||
|
||
type Props = { | ||
_id: Organization["_id"]; | ||
studies: Organization["studies"]; | ||
}; | ||
|
||
const StyledStudyCount = styled(Typography)<{ component: ElementType }>(({ theme }) => ({ | ||
textDecoration: "underline", | ||
cursor: "pointer", | ||
color: theme.palette.primary.main, | ||
})); | ||
|
||
const TooltipBody: FC<Props> = ({ _id, studies }) => ( | ||
<Typography variant="body1"> | ||
{studies?.map(({ studyName, studyAbbreviation }) => ( | ||
<React.Fragment key={`${_id}_study_${studyName}`}> | ||
{formatFullStudyName(studyName, studyAbbreviation)} | ||
<br /> | ||
</React.Fragment> | ||
))} | ||
</Typography> | ||
); | ||
|
||
/** | ||
* Organization list view tooltip for studies | ||
* | ||
* @param Props | ||
* @returns {React.FC} | ||
*/ | ||
const StudyTooltip: FC<Props> = ({ _id, studies }) => ( | ||
<Tooltip | ||
title={<TooltipBody _id={_id} studies={studies} />} | ||
placement="top" | ||
open={undefined} | ||
onBlur={undefined} | ||
disableHoverListener={false} | ||
arrow | ||
> | ||
<StyledStudyCount variant="body2" component="span"> | ||
other | ||
{" "} | ||
{studies.length - 1} | ||
</StyledStudyCount> | ||
</Tooltip> | ||
); | ||
|
||
export default StudyTooltip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters