@intersect.mbo/govtool-delegation-pillar
Version:
Delegation Pillar of the GovTool project
25 lines (21 loc) • 760 B
text/typescript
import { UseQueryOptions, useQuery } from 'react-query';
import { QUERY_KEYS } from 'consts';
import { usePillarContext } from 'context';
import { getVoterInfo } from 'services';
export const useGetVoterInfo = (options?: UseQueryOptions) => {
const { apiUrl, dRepID, pendingTransaction } = usePillarContext();
const { data } = useQuery({
queryKey: [
QUERY_KEYS.useGetDRepInfoKey,
(
pendingTransaction?.registerAsDrep ||
pendingTransaction?.registerAsDirectVoter ||
pendingTransaction?.retireAsDrep ||
pendingTransaction?.retireAsDirectVoter
)?.transactionHash,
],
enabled: !!dRepID && options?.enabled,
queryFn: () => getVoterInfo({ apiUrl, dRepID }),
});
return { voter: data };
};