diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index c0dc874b..482640da 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -109,7 +109,7 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos existingEntry.total += totalCardCount.total; acc[totalCardCount.name] = existingEntry; } else { - acc[totalCardCount.name] = totalCardCount; + acc[totalCardCount.name] = { ...totalCardCount }; } return acc; }, {} as Record); @@ -188,16 +188,15 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos const filteredCounts: TotalCardCounts[] = counts.filter(item => { if (filters && Object.entries(filters).length) { - return Object.entries(filters).every(([key, value]) => { - if (!value) { - return true; - } - if (key === "incidentStatus") { - return value === item.incidentStatus; - } else if (key === "disease" || key === "hazard") { - return value === item.name; - } - }); + const matchesDisease = + !filters.disease || (item.type === "disease" && item.name === filters.disease); + const matchesHazard = + !filters.hazard || (item.type === "hazard" && item.name === filters.hazard); + const matchesIncidentStatus = !filters.incidentStatus + ? item.incidentStatus === "ALL" + : item.incidentStatus === filters.incidentStatus; + + return matchesDisease && matchesHazard && matchesIncidentStatus; } return true; }); diff --git a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts index 9a1c3634..59596a6b 100644 --- a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts +++ b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts @@ -53,7 +53,7 @@ export type PerformanceOverviewMetrics = { nationalIncidentStatus: string; }; -export type IncidentStatus = "Watch" | "Alert" | "Respond" | "All"; +export type IncidentStatus = "Watch" | "Alert" | "Respond" | "ALL"; type BaseCounts = { name: DiseaseNames | HazardNames;