import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import * as api from '../lib/api';

export function usePushStats() {
  return useQuery({
    queryKey: ['push', 'stats'],
    queryFn: api.fetchPushStats,
  });
}

export function useSendPushNotification() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: api.sendPushNotification,
    onSuccess: () => {
      void queryClient.invalidateQueries({ queryKey: ['push', 'stats'] });
    },
  });
}
