Skip to content

Commit

Permalink
fix: voting votes filter by party
Browse files Browse the repository at this point in the history
  • Loading branch information
Th1nkK1D committed Oct 24, 2024
1 parent 553845e commit 720ad2c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/routes/votings/[id]/votes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script lang="ts">
import type { DefaultVoteOption, CustomVoteOption } from '$models/voting.js';
import type { SelectedCheckboxValueType } from '$components/DataPage/DataPage.svelte';
import type {
SelectedCheckboxValueType,
SelectedComboboxValueType
} from '$components/DataPage/DataPage.svelte';
import DataPage from '$components/DataPage/DataPage.svelte';
import VotingOptionTag from '$components/VotingOptionTag/VotingOptionTag.svelte';
Expand Down Expand Up @@ -41,6 +44,7 @@
let searchQuery = '';
let selectedCheckboxValue: SelectedCheckboxValueType;
let selectedComboboxValue: SelectedComboboxValueType;
$: filteredData =
selectedCheckboxValue === undefined ||
Expand All @@ -49,10 +53,13 @@
: votes.filter((vote) => {
const search = searchQuery.trim();
if (search && !vote.politician.id.includes(search)) return;
const selectedParty = selectedComboboxValue?.filterComboboxType;
const { filterPosition, filterVoteType } = selectedCheckboxValue;
return (
filterVoteType.includes(generalVoteType(vote.voteOption)) &&
filterPosition.includes(vote.role)
filterPosition.includes(vote.role) &&
(!selectedParty || vote.party === selectedParty)
);
});
Expand Down Expand Up @@ -83,6 +90,7 @@
]}
bind:searchQuery
bind:selectedCheckboxValue
bind:selectedComboboxValue
>
<div class="flex flex-col gap-1 md:flex-row md:items-center md:gap-16">
<div class="flex-1">
Expand Down

0 comments on commit 720ad2c

Please sign in to comment.