2024-10-21 03:19:54 -07:00
|
|
|
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();
|
|
|
|
|
2024-10-24 14:46:22 -07:00
|
|
|
return useQuery({
|
2024-10-21 03:19:54 -07:00
|
|
|
queryKey: ['polls', 'entities', pollId],
|
|
|
|
queryFn: () => client.polls.getPoll(pollId!),
|
|
|
|
enabled: !!pollId,
|
|
|
|
}, queryClient);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { usePoll };
|