Skip to content

Commit

Permalink
Merge pull request #43 from EyeSeeTea/fix/total-card-counts-bug
Browse files Browse the repository at this point in the history
fix: show only items with "ALL" incident status
  • Loading branch information
bhavananarayanan authored Dec 16, 2024
2 parents 4adcbff + b75586a commit 54de750
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/data/repositories/PerformanceOverviewD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, TotalCardCounts>);
Expand Down Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 54de750

Please sign in to comment.