import { useQuery } from '@tanstack/react-query';
import { PendingCountResponseSchema } from '@sar/api-interface';
import { apiFetch } from '../api-client';

export function usePendingCount() {
  return useQuery({
    queryKey: ['notifications', 'pending-count'],
    queryFn: async () => {
      const res = await apiFetch('/notifications/pending-count');
      return PendingCountResponseSchema.parse(res);
    },
    refetchInterval: 30_000,
    staleTime: 20_000,
  });
}
