From 718631e668c758982e0116a8a016f0f8e630a96d Mon Sep 17 00:00:00 2001 From: Ana Garcia Date: Fri, 27 Dec 2024 14:44:51 +0100 Subject: [PATCH 1/3] Add 717 Alerts cards in dashboards --- .../PerformanceOverviewD2Repository.ts | 158 ++++++++++-------- .../test/PerformanceOverviewTestRepository.ts | 10 +- .../PerformanceOverviewMetrics.ts | 2 +- .../PerformanceOverviewRepository.ts | 5 +- .../usecases/Get717PerformanceUseCase.ts | 12 +- src/webapp/pages/dashboard/DashboardPage.tsx | 30 +++- .../pages/dashboard/use717Performance.ts | 6 +- .../pages/event-tracker/EventTrackerPage.tsx | 5 +- 8 files changed, 137 insertions(+), 91 deletions(-) diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index 4f88ea4c..fc603952 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -606,39 +606,98 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos .value(); } - getDashboard717Performance(): FutureData { - return this.datastore - .getObject(PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY) - .flatMap(nullable717PerformanceProgramIndicators => { - return assertOrError( - nullable717PerformanceProgramIndicators, - PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY - ).flatMap(performance717ProgramIndicators => { - const dashboard717PerformanceIndicator = performance717ProgramIndicators.filter( - indicator => indicator.key === "dashboard" + getNational717Performance(): FutureData { + return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { + const dashboard717PerformanceIndicator = performance717ProgramIndicators.filter( + indicator => indicator.key === "national" + ); + return apiToFuture( + this.api.analytics.get({ + dimension: [ + `dx:${dashboard717PerformanceIndicator.map(({ id }) => id).join(";")}`, + ], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + includeMetadataDetails: true, + }) + ).map(res => { + return this.mapIndicatorsTo717PerformanceMetrics( + res.rows, + dashboard717PerformanceIndicator + ); + }); + }); + } + + getAlerts717Performance(): FutureData { + return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { + const dashboard717PerformanceIndicator = performance717ProgramIndicators.filter( + indicator => indicator.key === "alerts" + ); + + return apiToFuture( + this.api.analytics.get({ + dimension: [ + `dx:${dashboard717PerformanceIndicator.map(({ id }) => id).join(";")}`, + ], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + includeMetadataDetails: true, + }) + ).map(res => { + return this.mapIndicatorsTo717PerformanceMetrics( + res.rows, + dashboard717PerformanceIndicator + ); + }); + }); + } + + getEvent717Performance(diseaseOutbreakEventId: Id): FutureData { + return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { + const eventTracker717PerformanceIndicator = performance717ProgramIndicators.filter( + indicator => indicator.key === "event" + ); + return apiToFuture( + this.api.analytics.getEnrollmentsQuery({ + programId: RTSL_ZEBRA_PROGRAM_ID, + dimension: [...eventTracker717PerformanceIndicator.map(({ id }) => id)], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + }) + ).flatMap(response => { + const filteredRow = filterAnalyticsEnrollmentDataByDiseaseOutbreakEvent( + diseaseOutbreakEventId, + response.rows, + response.headers + ); + + if (!filteredRow) + return Future.error( + new Error("No data found for event tracker 7-1-7 performance") ); - return apiToFuture( - this.api.analytics.get({ - dimension: [ - `dx:${dashboard717PerformanceIndicator - .map(({ id }) => id) - .join(";")}`, - ], - startDate: DEFAULT_START_DATE, - endDate: DEFAULT_END_DATE, - includeMetadataDetails: true, - }) - ).map(res => { - return this.mapIndicatorsTo717PerformanceMetrics( - res.rows, - dashboard717PerformanceIndicator - ); - }); - }); + + const mappedIndicatorsToRows: string[][] = eventTracker717PerformanceIndicator.map( + ({ id }) => { + return [ + id, + filteredRow[response.headers.findIndex(header => header.name === id)] || + "", + ]; + } + ); + + return Future.success( + this.mapIndicatorsTo717PerformanceMetrics( + mappedIndicatorsToRows, + eventTracker717PerformanceIndicator + ) + ); }); + }); } - getEventTracker717Performance(diseaseOutbreakEventId: Id): FutureData { + private getAll717PerformanceIndicators(): FutureData { return this.datastore .getObject(PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY) .flatMap(nullable717PerformanceProgramIndicators => { @@ -646,46 +705,7 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos nullable717PerformanceProgramIndicators, PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY ).flatMap(performance717ProgramIndicators => { - const eventTracker717PerformanceIndicator = - performance717ProgramIndicators.filter( - indicator => indicator.key === "event_tracker" - ); - return apiToFuture( - this.api.analytics.getEnrollmentsQuery({ - programId: RTSL_ZEBRA_PROGRAM_ID, - dimension: [...eventTracker717PerformanceIndicator.map(({ id }) => id)], - startDate: DEFAULT_START_DATE, - endDate: DEFAULT_END_DATE, - }) - ).flatMap(response => { - const filteredRow = filterAnalyticsEnrollmentDataByDiseaseOutbreakEvent( - diseaseOutbreakEventId, - response.rows, - response.headers - ); - - if (!filteredRow) - return Future.error( - new Error("No data found for event tracker 7-1-7 performance") - ); - - const mappedIndicatorsToRows: string[][] = - eventTracker717PerformanceIndicator.map(({ id }) => { - return [ - id, - filteredRow[ - response.headers.findIndex(header => header.name === id) - ] || "", - ]; - }); - - return Future.success( - this.mapIndicatorsTo717PerformanceMetrics( - mappedIndicatorsToRows, - eventTracker717PerformanceIndicator - ) - ); - }); + return Future.success(performance717ProgramIndicators); }); }); } diff --git a/src/data/repositories/test/PerformanceOverviewTestRepository.ts b/src/data/repositories/test/PerformanceOverviewTestRepository.ts index 311d911c..986c637c 100644 --- a/src/data/repositories/test/PerformanceOverviewTestRepository.ts +++ b/src/data/repositories/test/PerformanceOverviewTestRepository.ts @@ -6,9 +6,7 @@ import { PerformanceOverviewRepository } from "../../../domain/repositories/Perf import { FutureData } from "../../api-futures"; export class PerformanceOverviewTestRepository implements PerformanceOverviewRepository { - getEventTracker717Performance( - _diseaseOutbreakEventId: Id - ): FutureData { + getEvent717Performance(_diseaseOutbreakEventId: Id): FutureData { return Future.success([]); } getEventTrackerOverviewMetrics(): FutureData { @@ -17,7 +15,11 @@ export class PerformanceOverviewTestRepository implements PerformanceOverviewRep getTotalCardCounts(): FutureData { return Future.success(0); } - getDashboard717Performance(): FutureData { + getNational717Performance(): FutureData { + return Future.success(0); + } + + getAlerts717Performance(): FutureData { return Future.success(0); } diff --git a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts index cbad5dfd..87b5c552 100644 --- a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts +++ b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts @@ -79,5 +79,5 @@ export type PerformanceMetrics717 = { name: string; type: "primary" | "secondary"; value?: number | "Inc"; - key: "dashboard" | "event_tracker"; + key: "national" | "event" | "alerts"; }; diff --git a/src/domain/repositories/PerformanceOverviewRepository.ts b/src/domain/repositories/PerformanceOverviewRepository.ts index 6704844a..8920bab6 100644 --- a/src/domain/repositories/PerformanceOverviewRepository.ts +++ b/src/domain/repositories/PerformanceOverviewRepository.ts @@ -21,8 +21,9 @@ export interface PerformanceOverviewRepository { multiSelectFilters?: Record, dateRangeFilter?: string[] ): FutureData; - getDashboard717Performance(): FutureData; - getEventTracker717Performance(diseaseOutbreakEventId: Id): FutureData; + getNational717Performance(): FutureData; + getEvent717Performance(diseaseOutbreakEventId: Id): FutureData; + getAlerts717Performance(): FutureData; getEventTrackerOverviewMetrics( type: string, casesDataSource: CasesDataSource diff --git a/src/domain/usecases/Get717PerformanceUseCase.ts b/src/domain/usecases/Get717PerformanceUseCase.ts index bdd78f59..40b0555f 100644 --- a/src/domain/usecases/Get717PerformanceUseCase.ts +++ b/src/domain/usecases/Get717PerformanceUseCase.ts @@ -11,15 +11,17 @@ export class Get717PerformanceUseCase { ) {} public execute( - type: "dashboard" | "event_tracker", + type: "national" | "event" | "alerts", diseaseOutbreakEventId: Id | undefined ): FutureData { - if (type === "event_tracker" && diseaseOutbreakEventId) { - return this.options.performanceOverviewRepository.getEventTracker717Performance( + if (type === "event" && diseaseOutbreakEventId) { + return this.options.performanceOverviewRepository.getEvent717Performance( diseaseOutbreakEventId ); - } else if (type === "dashboard") { - return this.options.performanceOverviewRepository.getDashboard717Performance(); + } else if (type === "national") { + return this.options.performanceOverviewRepository.getNational717Performance(); + } else if (type === "alerts") { + return this.options.performanceOverviewRepository.getAlerts717Performance(); } else throw new Error(`Unknown 717 type: ${type} `); } } diff --git a/src/webapp/pages/dashboard/DashboardPage.tsx b/src/webapp/pages/dashboard/DashboardPage.tsx index 93d95dfe..397ae4a4 100644 --- a/src/webapp/pages/dashboard/DashboardPage.tsx +++ b/src/webapp/pages/dashboard/DashboardPage.tsx @@ -40,7 +40,14 @@ export const DashboardPage: React.FC = React.memo(() => { isLoading: performanceOverviewLoading, } = usePerformanceOverview(); - const { performanceMetrics717, isLoading: _717CardsLoading } = use717Performance("dashboard"); + const { + performanceMetrics717: nationalPerformanceMetrics717, + isLoading: national717CardsLoading, + } = use717Performance("national"); + + const { performanceMetrics717: alertsPerformanceMetrics717, isLoading: alerts717CardsLoading } = + use717Performance("alerts"); + const { cardCounts, isLoading: cardCountsLoading } = useCardCounts( singleSelectFilters, multiSelectFilters, @@ -55,7 +62,7 @@ export const DashboardPage: React.FC = React.memo(() => { resetCurrentEventTrackerId(); }, [resetCurrentEventTrackerId]); - return performanceOverviewLoading || _717CardsLoading ? ( + return performanceOverviewLoading || national717CardsLoading || alerts717CardsLoading ? ( ) : ( { dateRangeFilter={dateRangeFilter.value} /> +
+ + {alertsPerformanceMetrics717.map( + (perfMetric717: PerformanceMetric717, index: number) => ( + + ) + )} + +
- {performanceMetrics717.map( + {nationalPerformanceMetrics717.map( (perfMetric717: PerformanceMetric717, index: number) => ( { - if (type === "dashboard") { + (key: string, value: number | "Inc", type: "national" | "event" | "alerts"): CardColors => { + if (type === "national") { switch (key) { case "allTargets": return "grey"; diff --git a/src/webapp/pages/event-tracker/EventTrackerPage.tsx b/src/webapp/pages/event-tracker/EventTrackerPage.tsx index 5901bda0..b2aa8740 100644 --- a/src/webapp/pages/event-tracker/EventTrackerPage.tsx +++ b/src/webapp/pages/event-tracker/EventTrackerPage.tsx @@ -74,10 +74,7 @@ export const EventTrackerPage: React.FC = React.memo(() => { }); }, [goTo]); - const { performanceMetrics717, isLoading: _717CardsLoading } = use717Performance( - "event_tracker", - id - ); + const { performanceMetrics717, isLoading: _717CardsLoading } = use717Performance("event", id); useEffect(() => { if (eventTrackerDetails) { From 9e15fdd46096729764e0d62522c855bb9421a6e8 Mon Sep 17 00:00:00 2001 From: Ana Garcia Date: Fri, 27 Dec 2024 14:48:24 +0100 Subject: [PATCH 2/3] Update translations --- i18n/en.pot | 9 ++++++--- i18n/es.po | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index d71006e1..c037d484 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-12-23T12:10:07.048Z\n" -"PO-Revision-Date: 2024-12-23T12:10:07.048Z\n" +"POT-Creation-Date: 2024-12-27T13:45:20.506Z\n" +"PO-Revision-Date: 2024-12-27T13:45:20.506Z\n" msgid "Low" msgstr "" @@ -171,12 +171,15 @@ msgstr "" msgid "All public health events" msgstr "" -msgid "7-1-7 performance" +msgid "Alerts 7-1-7 performance" msgstr "" msgid "events" msgstr "" +msgid "7-1-7 performance" +msgstr "" + msgid "Performance overview" msgstr "" diff --git a/i18n/es.po b/i18n/es.po index 154f2670..6ca27edd 100644 --- a/i18n/es.po +++ b/i18n/es.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: i18next-conv\n" -"POT-Creation-Date: 2024-12-23T12:07:43.318Z\n" +"POT-Creation-Date: 2024-12-27T13:45:20.506Z\n" "PO-Revision-Date: 2018-10-25T09:02:35.143Z\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -170,12 +170,15 @@ msgstr "" msgid "All public health events" msgstr "" -msgid "7-1-7 performance" +msgid "Alerts 7-1-7 performance" msgstr "" msgid "events" msgstr "" +msgid "7-1-7 performance" +msgstr "" + msgid "Performance overview" msgstr "" From 560b1663175dea6a4ba606151791b3b0ebdd67f6 Mon Sep 17 00:00:00 2001 From: Ana Garcia Date: Thu, 2 Jan 2025 13:37:45 +0100 Subject: [PATCH 3/3] Split in different keys in datastore 717 performance metricts indicators --- .../PerformanceOverviewD2Repository.ts | 187 +++++++++--------- .../PerformanceOverviewMetrics.ts | 4 +- .../usecases/Get717PerformanceUseCase.ts | 7 +- .../pages/dashboard/use717Performance.ts | 9 +- 4 files changed, 113 insertions(+), 94 deletions(-) diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index fc603952..d03c8c3b 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -23,6 +23,7 @@ import { DiseaseNames, PerformanceMetrics717, IncidentStatus, + PerformanceMetrics717Key, } from "../../domain/entities/disease-outbreak-event/PerformanceOverviewMetrics"; import { Id } from "../../domain/entities/Ref"; import { OverviewCard } from "../../domain/entities/PerformanceOverview"; @@ -47,7 +48,12 @@ const ALERTS_PROGRAM_EVENT_TRACKER_OVERVIEW_DATASTORE_KEY = "alerts-program-event-tracker-overview-ids"; const CASES_PROGRAM_EVENT_TRACKER_OVERVIEW_DATASTORE_KEY = "cases-program-event-tracker-overview-ids"; -const PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY = "717-performance-program-indicators"; +const NATIONAL_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY = + "national-717-performance-program-indicators"; +const EVENT_TRACKER_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY = + "event-tracker-717-performance-program-indicators"; +const ALERTS_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY = + "alerts-717-performance-program-indicators"; const PERFORMANCE_OVERVIEW_DIMENSIONS_DATASTORE_KEY = "performance-overview-dimensions"; type EventTrackerOverviewInDataStore = { @@ -607,106 +613,111 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos } getNational717Performance(): FutureData { - return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { - const dashboard717PerformanceIndicator = performance717ProgramIndicators.filter( - indicator => indicator.key === "national" - ); - return apiToFuture( - this.api.analytics.get({ - dimension: [ - `dx:${dashboard717PerformanceIndicator.map(({ id }) => id).join(";")}`, - ], - startDate: DEFAULT_START_DATE, - endDate: DEFAULT_END_DATE, - includeMetadataDetails: true, - }) - ).map(res => { - return this.mapIndicatorsTo717PerformanceMetrics( - res.rows, - dashboard717PerformanceIndicator - ); - }); - }); + return this.get717PerformanceIndicators("national").flatMap( + performance717ProgramIndicators => { + return apiToFuture( + this.api.analytics.get({ + dimension: [ + `dx:${performance717ProgramIndicators.map(({ id }) => id).join(";")}`, + ], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + includeMetadataDetails: true, + }) + ).map(res => { + return this.mapIndicatorsTo717PerformanceMetrics( + res.rows, + performance717ProgramIndicators + ); + }); + } + ); } getAlerts717Performance(): FutureData { - return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { - const dashboard717PerformanceIndicator = performance717ProgramIndicators.filter( - indicator => indicator.key === "alerts" - ); - - return apiToFuture( - this.api.analytics.get({ - dimension: [ - `dx:${dashboard717PerformanceIndicator.map(({ id }) => id).join(";")}`, - ], - startDate: DEFAULT_START_DATE, - endDate: DEFAULT_END_DATE, - includeMetadataDetails: true, - }) - ).map(res => { - return this.mapIndicatorsTo717PerformanceMetrics( - res.rows, - dashboard717PerformanceIndicator - ); - }); - }); + return this.get717PerformanceIndicators("alerts").flatMap( + performance717ProgramIndicators => { + return apiToFuture( + this.api.analytics.get({ + dimension: [ + `dx:${performance717ProgramIndicators.map(({ id }) => id).join(";")}`, + ], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + includeMetadataDetails: true, + }) + ).map(res => { + return this.mapIndicatorsTo717PerformanceMetrics( + res.rows, + performance717ProgramIndicators + ); + }); + } + ); } getEvent717Performance(diseaseOutbreakEventId: Id): FutureData { - return this.getAll717PerformanceIndicators().flatMap(performance717ProgramIndicators => { - const eventTracker717PerformanceIndicator = performance717ProgramIndicators.filter( - indicator => indicator.key === "event" - ); - return apiToFuture( - this.api.analytics.getEnrollmentsQuery({ - programId: RTSL_ZEBRA_PROGRAM_ID, - dimension: [...eventTracker717PerformanceIndicator.map(({ id }) => id)], - startDate: DEFAULT_START_DATE, - endDate: DEFAULT_END_DATE, - }) - ).flatMap(response => { - const filteredRow = filterAnalyticsEnrollmentDataByDiseaseOutbreakEvent( - diseaseOutbreakEventId, - response.rows, - response.headers - ); - - if (!filteredRow) - return Future.error( - new Error("No data found for event tracker 7-1-7 performance") + return this.get717PerformanceIndicators("event").flatMap( + performance717ProgramIndicators => { + return apiToFuture( + this.api.analytics.getEnrollmentsQuery({ + programId: RTSL_ZEBRA_PROGRAM_ID, + dimension: [...performance717ProgramIndicators.map(({ id }) => id)], + startDate: DEFAULT_START_DATE, + endDate: DEFAULT_END_DATE, + }) + ).flatMap(response => { + const filteredRow = filterAnalyticsEnrollmentDataByDiseaseOutbreakEvent( + diseaseOutbreakEventId, + response.rows, + response.headers ); - const mappedIndicatorsToRows: string[][] = eventTracker717PerformanceIndicator.map( - ({ id }) => { - return [ - id, - filteredRow[response.headers.findIndex(header => header.name === id)] || - "", - ]; - } - ); + if (!filteredRow) + return Future.error( + new Error("No data found for event tracker 7-1-7 performance") + ); - return Future.success( - this.mapIndicatorsTo717PerformanceMetrics( - mappedIndicatorsToRows, - eventTracker717PerformanceIndicator - ) - ); - }); - }); + const mappedIndicatorsToRows: string[][] = performance717ProgramIndicators.map( + ({ id }) => { + return [ + id, + filteredRow[ + response.headers.findIndex(header => header.name === id) + ] || "", + ]; + } + ); + + return Future.success( + this.mapIndicatorsTo717PerformanceMetrics( + mappedIndicatorsToRows, + performance717ProgramIndicators + ) + ); + }); + } + ); } - private getAll717PerformanceIndicators(): FutureData { + private get717PerformanceIndicators( + key: PerformanceMetrics717Key + ): FutureData { + const datastoreKey = + key === "national" + ? NATIONAL_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY + : key === "alerts" + ? ALERTS_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY + : EVENT_TRACKER_PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY; + return this.datastore - .getObject(PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY) + .getObject(datastoreKey) .flatMap(nullable717PerformanceProgramIndicators => { - return assertOrError( - nullable717PerformanceProgramIndicators, - PERFORMANCE_717_PROGRAM_INDICATORS_DATASTORE_KEY - ).flatMap(performance717ProgramIndicators => { - return Future.success(performance717ProgramIndicators); - }); + return assertOrError(nullable717PerformanceProgramIndicators, datastoreKey).flatMap( + performance717ProgramIndicators => { + return Future.success(performance717ProgramIndicators); + } + ); }); } diff --git a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts index 87b5c552..b9bdec7b 100644 --- a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts +++ b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts @@ -74,10 +74,12 @@ type HazardCounts = BaseCounts & { export type TotalCardCounts = DiseaseCounts | HazardCounts; +export type PerformanceMetrics717Key = "national" | "event" | "alerts"; + export type PerformanceMetrics717 = { id: string; name: string; type: "primary" | "secondary"; value?: number | "Inc"; - key: "national" | "event" | "alerts"; + key: PerformanceMetrics717Key; }; diff --git a/src/domain/usecases/Get717PerformanceUseCase.ts b/src/domain/usecases/Get717PerformanceUseCase.ts index 40b0555f..cf73e57c 100644 --- a/src/domain/usecases/Get717PerformanceUseCase.ts +++ b/src/domain/usecases/Get717PerformanceUseCase.ts @@ -1,5 +1,8 @@ import { FutureData } from "../../data/api-futures"; -import { PerformanceMetrics717 } from "../entities/disease-outbreak-event/PerformanceOverviewMetrics"; +import { + PerformanceMetrics717, + PerformanceMetrics717Key, +} from "../entities/disease-outbreak-event/PerformanceOverviewMetrics"; import { Id } from "../entities/Ref"; import { PerformanceOverviewRepository } from "../repositories/PerformanceOverviewRepository"; @@ -11,7 +14,7 @@ export class Get717PerformanceUseCase { ) {} public execute( - type: "national" | "event" | "alerts", + type: PerformanceMetrics717Key, diseaseOutbreakEventId: Id | undefined ): FutureData { if (type === "event" && diseaseOutbreakEventId) { diff --git a/src/webapp/pages/dashboard/use717Performance.ts b/src/webapp/pages/dashboard/use717Performance.ts index 0610bfb1..3c1ce979 100644 --- a/src/webapp/pages/dashboard/use717Performance.ts +++ b/src/webapp/pages/dashboard/use717Performance.ts @@ -2,7 +2,10 @@ import { useCallback, useEffect, useState } from "react"; import { useAppContext } from "../../contexts/app-context"; import _ from "../../../domain/entities/generic/Collection"; import { StatsCardProps } from "../../components/stats-card/StatsCard"; -import { PerformanceMetrics717 } from "../../../domain/entities/disease-outbreak-event/PerformanceOverviewMetrics"; +import { + PerformanceMetrics717, + PerformanceMetrics717Key, +} from "../../../domain/entities/disease-outbreak-event/PerformanceOverviewMetrics"; import { Id } from "../../../domain/entities/Ref"; type CardColors = StatsCardProps["color"]; @@ -25,7 +28,7 @@ export type PerformanceMetric717State = { export type Order = { name: string; direction: "asc" | "desc" }; export function use717Performance( - type: "national" | "event" | "alerts", + type: PerformanceMetrics717Key, diseaseOutbreakEventId?: Id ): PerformanceMetric717State { const { compositionRoot } = useAppContext(); @@ -34,7 +37,7 @@ export function use717Performance( const [isLoading, setIsLoading] = useState(false); const getColor = useCallback( - (key: string, value: number | "Inc", type: "national" | "event" | "alerts"): CardColors => { + (key: string, value: number | "Inc", type: PerformanceMetrics717Key): CardColors => { if (type === "national") { switch (key) { case "allTargets":