@@ -10,10 +10,15 @@ import {
1010 TooltipProps ,
1111} from "@mui/material" ;
1212import { useLazyQuery } from "@apollo/client" ;
13- import { getEntityIcon , getEntityQuery , getQueryVariables } from "./utils/asyncTooltipUtil" ;
13+ import {
14+ getEntityDescription ,
15+ getEntityIcon ,
16+ getEntityQuery ,
17+ getQueryVariables ,
18+ } from "./utils/asyncTooltipUtil" ;
1419import { naLabel } from "@ot/constants" ;
1520
16- import { getStudyItemMetaData } from "@ot/utils " ;
21+ import StudyPublication from "../StudyPublication " ;
1722
1823const DELAY_REQUEST = 1000 ;
1924
@@ -56,8 +61,10 @@ function OtAsyncTooltip({ children, entity, id }: OtAsyncTooltipProps): ReactEle
5661 } ) ;
5762
5863 function getTooltipContent ( ) {
64+ let entityAccessor = entity ;
5965 if ( loading || ! data ) return < AsyncTooltipLoadingView /> ;
60- return < AsyncTooltipDataView entity = { entity } data = { data ?. [ entity ] } /> ;
66+ if ( entity === "credible-set" ) entityAccessor = "credibleSet" ;
67+ return < AsyncTooltipDataView entity = { entity } data = { data ?. [ entityAccessor ] } /> ;
6168 }
6269
6370 function abortApiCall ( ) {
@@ -119,41 +126,33 @@ function AsyncTooltipDataView({
119126 entity : string ;
120127 data : Record < string , unknown > ;
121128} ) : ReactElement {
122- function getLabel ( ) {
123- return data ?. name || data ?. id || naLabel ;
124- }
125-
126- function getDescription ( ) {
127- let descText = "" ;
128-
129- if ( Array . isArray ( data . description ) && data . description . length )
130- descText = data ?. description [ 0 ] . substring ( 0 , 150 ) ;
131- else if ( Array . isArray ( data . description ) && ! data . description . length ) descText = "" ;
132- else if ( data . description ) descText = data ?. description . substring ( 0 , 150 ) ;
133-
134- // study subtext
135- descText += getStudyItemMetaData ( {
136- studyType : data ?. studyType ,
137- nSamples : data ?. nSamples ,
138- credibleSetsCount : data ?. credibleSets ?. credibleSetsCount ,
139- } ) ;
140-
141- if ( ! descText ) return "No description available." ;
142-
143- return descText ;
144- }
129+ const showSubText = ! ! data ?. mostSevereConsequence ?. label || data ?. publicationFirstAuthor ;
145130
146131 function getSubtext ( ) {
147- let finalSubText = "" ;
132+ let finalSubText ;
148133
134+ // variant subtext
149135 const mostSevereConsequence = data ?. mostSevereConsequence ?. label ;
136+ if ( mostSevereConsequence ) finalSubText = `Most severe consequence: ${ mostSevereConsequence } ` ;
150137
151- if ( mostSevereConsequence ) finalSubText += `Most severe consequence: ${ mostSevereConsequence } ` ;
138+ // study subtext
139+ const publicationData = data ?. publicationFirstAuthor ;
140+ if ( publicationData )
141+ finalSubText = (
142+ < StudyPublication
143+ publicationDate = { data ?. publicationDate }
144+ publicationFirstAuthor = { data ?. publicationFirstAuthor }
145+ publicationJournal = { data ?. publicationJournal }
146+ />
147+ ) ;
152148
153149 return finalSubText ;
154150 }
155151
156- const showSubText = ! ! data ?. mostSevereConsequence ?. label ;
152+ function getLabel ( ) {
153+ if ( entity === "credible-set" ) return "Credible set" ;
154+ return data ?. name || data ?. id || naLabel ;
155+ }
157156
158157 return (
159158 < Box sx = { { p : 1 } } >
@@ -184,7 +183,7 @@ function AsyncTooltipDataView({
184183 { getLabel ( ) }
185184 </ Box > { " " }
186185 < Box sx = { { typography : "body2" , color : theme => theme . palette . grey [ 800 ] } } >
187- { getDescription ( ) }
186+ { getEntityDescription ( entity , data ) }
188187 </ Box >
189188 </ Box >
190189 </ Box >
0 commit comments