Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(admin): Ballot Count Report Builder #4019

Merged
merged 15 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions apps/admin/frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,16 @@ export const getCardCounts = {
queryKey(input?: GetCardCountsInput): QueryKey {
return input ? ['getCardCounts', input] : ['getCardCounts'];
},
useQuery(input: GetCardCountsInput = { groupBy: {} }) {
useQuery(
input: GetCardCountsInput = { groupBy: {} },
options: { enabled: boolean } = { enabled: true }
) {
const apiClient = useApiClient();
return useQuery(this.queryKey(input), () => apiClient.getCardCounts(input));
return useQuery(
this.queryKey(input),
() => apiClient.getCardCounts(input),
options
);
},
} as const;

Expand Down Expand Up @@ -674,6 +681,13 @@ export const exportTallyReportCsv = {
},
} as const;

export const exportBallotCountReportCsv = {
useMutation() {
const apiClient = useApiClient();
return useMutation(apiClient.exportBallotCountReportCsv);
},
} as const;

export const saveBallotPackageToUsb = {
useMutation() {
const apiClient = useApiClient();
Expand Down
24 changes: 12 additions & 12 deletions apps/admin/frontend/src/components/ballot_counts_table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Ballot Counts by Precinct', () => {
];

it('renders as expected when there is no tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByPrecinct: true }),
[]
);
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('Ballot Counts by Precinct', () => {
});

it('renders as expected when there is tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByPrecinct: true }),
cardCountsByPrecinct
);
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Ballot Counts by Scanner', () => {
const scannerIds = ['scanner-1', 'scanner-2'];

it('renders as expected when there is no tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByScanner: true }),
[]
);
Expand All @@ -165,7 +165,7 @@ describe('Ballot Counts by Scanner', () => {
});

it('renders as expected when there is tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByScanner: true }),
cardCountsByScanner
);
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Ballot Counts by Scanner', () => {
});

it('renders as expected when there is tally data and manual data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByScanner: true }),
cardCountsByScanner
);
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('Ballots Counts by Party', () => {
];

it('renders as expected when there is no data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByParty: true }),
[]
);
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('Ballots Counts by Party', () => {
});

it('renders as expected when there is tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByParty: true }),
cardCountsByParty
);
Expand Down Expand Up @@ -369,7 +369,7 @@ describe('Ballots Counts by VotingMethod', () => {
];

it('renders as expected when there is no data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByVotingMethod: true }),
[]
);
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('Ballots Counts by VotingMethod', () => {
});

it('renders as expected when there is tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByVotingMethod: true }),
cardCountsByVotingMethod
);
Expand Down Expand Up @@ -483,7 +483,7 @@ describe('Ballots Counts by Batch', () => {
];

it('renders as expected when there is no data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByBatch: true }),
[]
);
Expand Down Expand Up @@ -521,7 +521,7 @@ describe('Ballots Counts by Batch', () => {
];

it('renders as expected when there is tally data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByBatch: true }),
cardCountsByBatch
);
Expand Down Expand Up @@ -561,7 +561,7 @@ describe('Ballots Counts by Batch', () => {
});

it('renders as expected where there is tally data and manual data', async () => {
apiMock.expectGetCardCounts(
apiMock.deprecatedExpectGetCardCounts(
mockBallotCountsTableGroupBy({ groupByBatch: true }),
cardCountsByBatch
);
Expand Down
4 changes: 4 additions & 0 deletions apps/admin/frontend/src/components/election_manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { checkPin } from '../api';
import { canViewAndPrintBallots } from '../utils/can_view_and_print_ballots';
import { WriteInsAdjudicationScreen } from '../screens/write_ins_adjudication_screen';
import { TallyReportBuilder } from '../screens/tally_report_builder';
import { BallotCountReportBuilder } from '../screens/ballot_count_report_builder';

export function ElectionManager(): JSX.Element {
const { electionDefinition, configuredAt, auth, hasCardReaderAttached } =
Expand Down Expand Up @@ -206,6 +207,9 @@ export function ElectionManager(): JSX.Element {
<Route exact path={routerPaths.tallyAllPrecinctsReport}>
<AllPrecinctsTallyReportScreen />
</Route>
<Route exact path={routerPaths.ballotCountReportBuilder}>
<BallotCountReportBuilder />
</Route>
<Route
exact
path={routerPaths.tallyVotingMethodReport({
Expand Down
Loading