From de89714deb9dab7e473e795037954f536715088e Mon Sep 17 00:00:00 2001 From: VWSCoronaDashboard26 Date: Wed, 14 Dec 2022 17:22:20 +0100 Subject: [PATCH] feat(severity-indicator): adjusted logic for getting thermometer timeline event title and description from the associated level definition rather than the event itself; adjusted tooltip content to properly show the updated contents; --- .../components/timeline/components/tooltip-content.tsx | 6 +++++- .../app/src/queries/get-topical-structure-query.ts | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/app/src/components/severity-indicator-tile/components/timeline/components/tooltip-content.tsx b/packages/app/src/components/severity-indicator-tile/components/timeline/components/tooltip-content.tsx index 37f137d05f..33b76b3dd3 100644 --- a/packages/app/src/components/severity-indicator-tile/components/timeline/components/tooltip-content.tsx +++ b/packages/app/src/components/severity-indicator-tile/components/timeline/components/tooltip-content.tsx @@ -73,7 +73,11 @@ export const TimelineTooltipContent = ({ config, hasMultipleEvents, onNext, onPr {config.title} - {config.description} + + {replaceVariablesInText(config.description.split('**').join(''), { + label: config.title.toLowerCase(), + })} + {currentEstimationLabel && ( diff --git a/packages/app/src/queries/get-topical-structure-query.ts b/packages/app/src/queries/get-topical-structure-query.ts index fade4f6206..ba7c76652f 100644 --- a/packages/app/src/queries/get-topical-structure-query.ts +++ b/packages/app/src/queries/get-topical-structure-query.ts @@ -108,16 +108,12 @@ export function getTopicalStructureQuery(locale: string) { } export const getThermometerEvents = (thermometerEvents: ThermometerTimelineEvent[], thermometerLevels: ThermometerLevel[]) => { - // 1. USE thermometerEvent.level TO FIND level IN thermometerLevels - // 2. USE level TO REFERENCE level.title AND level.description - return thermometerEvents.map((thermometerEvent) => { - // STEP 1 GOES HERE - const currentLevel = thermometerLevels?.find((thermometerLevel) => thermometerLevel.level === (thermometerEvent.level as SeverityLevel)); + const levelDetails = thermometerLevels.find((thermometerLevel) => thermometerLevel.level === (thermometerEvent.level as SeverityLevel)) as ThermometerLevel; return { - title: currentLevel?.label ?? thermometerEvent.title, // STEP 2.1 - title - description: currentLevel?.description ?? thermometerEvent.description, // STEP 2.2 - description + title: levelDetails.label, + description: levelDetails.description, level: thermometerEvent.level, start: new Date(thermometerEvent.date).getTime() / 1000, end: new Date(thermometerEvent.dateEnd).getTime() / 1000,