This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Display resource narrative #68
Open
BPierrick
wants to merge
7
commits into
main
Choose a base branch
from
pb/resource_narrative
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5b71044
chore: move constants file
BPierrick 80e370e
type: add `DomainResourceList` restricted type
BPierrick b9811f7
deps: add dompurify dependency
BPierrick 3efbdab
comp: add InnerHTMLDiv component
BPierrick 5bfa138
comp: Made Tooltip component with facultative `title`
BPierrick e7bd9f6
feat: plug Patient resource narrative tooltip on avatar
BPierrick e44504f
feat: display narrative for resources in CardContent
BPierrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,26 @@ | ||||||
import React from "react"; | ||||||
|
||||||
import DOMPurify from "dompurify"; | ||||||
|
||||||
type InnerHTMLDivProps = Omit< | ||||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, | ||||||
"dangerouslySetInnerHTML" | ||||||
> & { | ||||||
innerHTML?: string; | ||||||
}; | ||||||
|
||||||
const InnterHTMLDiv = ({ | ||||||
innerHTML, | ||||||
...props | ||||||
}: InnerHTMLDivProps): JSX.Element => { | ||||||
const sanitizedHTML = innerHTML && DOMPurify.sanitize(innerHTML); | ||||||
return ( | ||||||
<> | ||||||
{sanitizedHTML && ( | ||||||
<div {...props} dangerouslySetInnerHTML={{ __html: sanitizedHTML }} /> | ||||||
)} | ||||||
</> | ||||||
); | ||||||
}; | ||||||
|
||||||
export default InnterHTMLDiv; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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,22 @@ | ||
import React from "react"; | ||
|
||
import { | ||
Tooltip as MuiTooltip, | ||
TooltipProps as MuiTooltipProps, | ||
} from "@mui/material"; | ||
|
||
type TooltipProps = Omit<MuiTooltipProps, "title"> & { | ||
title?: React.ReactNode; | ||
}; | ||
|
||
const Tooltip = ({ title, children, ...props }: TooltipProps): JSX.Element => { | ||
return title ? ( | ||
<MuiTooltip title={title} {...props}> | ||
{children} | ||
</MuiTooltip> | ||
) : ( | ||
children | ||
); | ||
}; | ||
|
||
export default Tooltip; |
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
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 |
---|---|---|
|
@@ -9,6 +9,8 @@ import { DateTime } from "luxon"; | |
import { useTranslation } from "react-i18next"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
import InnterHTMLDiv from "common/components/InnerHTMLDiv"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inner ! |
||
import Tooltip from "common/components/Tooltip"; | ||
import { useApiPatientsListQuery } from "services/api/api"; | ||
|
||
import { getINS, getIPP } from "./utils"; | ||
|
@@ -74,11 +76,16 @@ const PatientInfo = (): JSX.Element => { | |
<CircularProgress /> | ||
) : ( | ||
<> | ||
<div className={classes.columnContainer}> | ||
<Avatar classes={{ root: classes.avatar }}> | ||
<PersonIcon fontSize="large" /> | ||
</Avatar> | ||
</div> | ||
<Tooltip | ||
followCursor | ||
title={<InnterHTMLDiv innerHTML={patient?.text?.div} />} | ||
> | ||
<div className={classes.columnContainer}> | ||
<Avatar classes={{ root: classes.avatar }}> | ||
<PersonIcon fontSize="large" /> | ||
</Avatar> | ||
</div> | ||
</Tooltip> | ||
<div className={classes.columnContainer}> | ||
<Typography | ||
className={classes.nameTitle} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
|
||
import { CardContent } from "@mui/material"; | ||
|
||
import InnterHTMLDiv from "common/components/InnerHTMLDiv"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inner ! |
||
import type { DomainResourceList } from "models/types"; | ||
|
||
type ResourceCardContentProps = { | ||
resource: DomainResourceList; | ||
}; | ||
|
||
const ResourceCardContent = ({ | ||
resource, | ||
}: ResourceCardContentProps): JSX.Element => { | ||
return ( | ||
<> | ||
{resource.text?.div && ( | ||
<CardContent> | ||
<InnterHTMLDiv innerHTML={resource.text.div} /> | ||
</CardContent> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ResourceCardContent; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.