diff --git a/src/components/Universe/Graph/Cubes/Cube/components/Tooltip/index.tsx b/src/components/Universe/Graph/Cubes/Cube/components/Tooltip/index.tsx index 475877313..875aad0f4 100644 --- a/src/components/Universe/Graph/Cubes/Cube/components/Tooltip/index.tsx +++ b/src/components/Universe/Graph/Cubes/Cube/components/Tooltip/index.tsx @@ -47,90 +47,30 @@ export const Tooltip = ({ node }: Props) => { type, name, twitter_handle: twitterHandle, + image_url: imageUrl, + guests: guestArray, } = node - const correctType = type?.toLowerCase() + const guests = guestArray && guestArray.length > 0 - const guestArray = node.guests + const isGuestArrObj = guests && typeof guestArray[0] === 'object' - let guests = false - let isGuestArrObj = false + let displayImageUrl = imageUrl - if (guestArray) { - if (guestArray.length && guestArray[0] !== null) { - guests = true - } - - if (typeof guestArray[0] === 'object') { - isGuestArrObj = true - } + if (nodeType === 'guest' && !imageUrl) { + displayImageUrl = 'person_placeholder2.png' + } else if (!imageUrl) { + displayImageUrl = 'noimage.jpeg' } - let imageUrl = node.image_url - - if (correctType === 'twitter_space') { - imageUrl = 'twitter_placeholder.png' - } - - if (imageUrl == null) { - switch (nodeType) { - case 'guest': - imageUrl = 'person_placeholder2.png' - break - default: - imageUrl = 'noimage.jpeg' - } + if (type === 'twitter_space') { + displayImageUrl = 'twitter_placeholder.png' } if (nodeType === 'topic') { return null } - const renderContent = () => { - switch (correctType) { - case 'guest': - return ( - - {label ?? name} - {text && ( - - - @{text} - - - )} - - ) - case 'person': - case 'event': - case 'topic': - case 'corporation': - case 'organization': - case 'thing': - case 'host': - case 'place': - case 'product': - return ( - - {name ?? label} - {correctType === 'person' && twitterHandle && ( - - - @{twitterHandle} - - - )} - - ) - default: - return ( - - {showTitle} - - ) - } - } - return ( {nodeType === 'tweet' ? ( @@ -146,50 +86,74 @@ export const Tooltip = ({ node }: Props) => { - +
- {renderContent()} + {(name || label) && ( + + {name ? ( + {name} + ) : ( + <> + {label} + {text && ( + + + @{text} + + + )} + + )} + + )} + + {showTitle && ( + + {showTitle} + + )} - - {nodeType === 'clip' || (nodeType === 'episode' && Episode)} + {episodeTitle && ( + + + {episodeTitle} + + + )} - {nodeType === 'clip' ? ( + {description && ( + {formatDescription(description)} - ) : ( + + )} + + {twitterHandle && ( + - {episodeTitle} + @{twitterHandle} - )} - - - - {nodeType === 'clip' && Episode} - - - {nodeType === 'clip' ? episodeTitle : formatDescription(description)} - - + + )} - {guests && ( + {guestArray && guestArray.length > 0 && ( People - {isGuestArrObj - ? (guestArray as Guests[]) - .map((guest) => { - if (guest.name) { - return guest.name - } - - return `@${guest.twitter_handle}` - }) - .join(', ') - : guestArray?.join(', ')} + {guests && ( + + Guests: + + {isGuestArrObj + ? (guestArray as Guests[]).map((guest) => `@${guest?.twitter_handle}`).join(', ') + : guestArray.join(', ')} + + + )}