Skip to content

Commit

Permalink
fix: set total data
Browse files Browse the repository at this point in the history
  • Loading branch information
songwongtp committed Apr 10, 2024
1 parent 0ce1da4 commit 3ebf1f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Flex, Grid, GridItem, TableContainer } from "@chakra-ui/react";
import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";
import type { ChangeEvent } from "react";

import { useMobile } from "lib/app-provider";
Expand Down Expand Up @@ -128,14 +128,10 @@ export const ValidatorVotesTable = ({
pageSize,
offset,
answerFilter,
debouncedSearch
debouncedSearch,
{ onSuccess: ({ total }) => setTotalData(total) }
);

// update total data because we do filter and search on frontend side
useEffect(() => {
setTotalData(data?.total ?? 0);
}, [data, setTotalData]);

const isSearching =
debouncedSearch !== "" || answerFilter !== ProposalVoteType.ALL;

Expand Down
9 changes: 7 additions & 2 deletions src/lib/services/proposalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import type {
ProposalAnswerCountsResponse,
ProposalDataResponse,
ProposalsResponse,
ProposalValidatorVotesResponse,
ProposalVotesResponse,
RelatedProposalsResponse,
UploadAccess,
Expand Down Expand Up @@ -384,7 +385,11 @@ export const useProposalValidatorVotes = (
limit: number,
offset: number,
answer: ProposalVoteType,
search: string
search: string,
options: Pick<
UseQueryOptions<ProposalValidatorVotesResponse>,
"onSuccess"
> = {}
) => {
const endpoint = useBaseApiRoute("proposals");

Expand All @@ -400,7 +405,7 @@ export const useProposalValidatorVotes = (
],
async () =>
getProposalValidatorVotes(endpoint, id, limit, offset, answer, search),
{ retry: 1, refetchOnWindowFocus: false }
{ retry: 1, refetchOnWindowFocus: false, ...options }
);
};

Expand Down

0 comments on commit 3ebf1f9

Please sign in to comment.