bigbuffet-rw/packages/pl-hooks/lib/hooks/polls/use-poll.ts
marcin mikołajczak d6aa4bf388 pl-hooks: Updates, add useStatusTranslation query
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-24 23:46:22 +02:00

17 lines
504 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import { usePlHooksApiClient } from 'pl-hooks/contexts/api-client';
import { usePlHooksQueryClient } from 'pl-hooks/contexts/query-client';
const usePoll = (pollId?: string) => {
const queryClient = usePlHooksQueryClient();
const { client } = usePlHooksApiClient();
return useQuery({
queryKey: ['polls', 'entities', pollId],
queryFn: () => client.polls.getPoll(pollId!),
enabled: !!pollId,
}, queryClient);
};
export { usePoll };