Skip to content

Commit

Permalink
[#1404] improve query data type from any
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Jul 5, 2024
1 parent 76b0459 commit 6a08db6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions govtool/frontend/src/context/pendingTransaction/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AutomatedVotingOptionCurrentDelegation,
AutomatedVotingOptionDelegationId,
} from "@/types/automatedVotingOptions";
import { CurrentDelegation, VoterInfo } from "@/models";

export const getDesiredResult = (
type: TransactionType,
Expand Down Expand Up @@ -61,11 +62,9 @@ export const refetchData = async (
if (queryKey === undefined) return;

await queryClient.invalidateQueries(queryKey);
// TODO add better type for query data
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data = await queryClient.getQueryData<any>(queryKey);

if (type === "delegate") {
const data = await queryClient.getQueryData<CurrentDelegation>(queryKey);
if (
resourceId === AutomatedVotingOptionDelegationId.no_confidence ||
resourceId === AutomatedVotingOptionDelegationId.abstain
Expand All @@ -74,6 +73,9 @@ export const refetchData = async (
}
return data?.dRepHash;
}

const data = await queryClient.getQueryData<VoterInfo>(queryKey);

if (type === "registerAsDrep" || type === "retireAsDrep")
return data?.isRegisteredAsDRep;
if (type === "registerAsDirectVoter" || type === "retireAsDirectVoter")
Expand Down

0 comments on commit 6a08db6

Please sign in to comment.