Skip to content

Commit

Permalink
fix: filter for total card counts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed Dec 11, 2024
1 parent d4e5092 commit d0d765f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/data/repositories/PerformanceOverviewD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,13 @@ 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 item.incidentStatus === "ALL";
}
if (key === "incidentStatus") {
return value === item.incidentStatus;
} else if (key === "disease" || key === "hazard") {
return value === item.name;
}
});
const matchesDisease = !filters.disease || item.name === filters.disease;
const matchesHazard = !filters.hazard || item.type === "hazard";
const matchesIncidentStatus = !filters.incidentStatus
? item.incidentStatus === "ALL"
: item.incidentStatus === filters.incidentStatus;

return matchesDisease && matchesHazard && matchesIncidentStatus;
}
return true;
});
Expand Down

0 comments on commit d0d765f

Please sign in to comment.