Skip to content

Commit

Permalink
feat(admin): Ballot Count Report Builder (#4019)
Browse files Browse the repository at this point in the history
  • Loading branch information
adghayes authored Oct 4, 2023
1 parent 33b9ee2 commit 767f4ef
Show file tree
Hide file tree
Showing 31 changed files with 1,743 additions and 109 deletions.
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

0 comments on commit 767f4ef

Please sign in to comment.