import { useQuery } from '@tanstack/react-query';
import {
  fetchNotifications,
  type FetchNotificationsParams,
} from '@/features/notifications/services/notificationService';

export const notificationsQueryKey = (params?: FetchNotificationsParams) =>
  ['notifications', 'list', params?.page ?? 1, params?.per_page ?? 15] as const;

export function useNotifications(params?: FetchNotificationsParams, enabled = true) {
  return useQuery({
    queryKey: notificationsQueryKey(params),
    queryFn: () => fetchNotifications(params),
    enabled,
    staleTime: 30_000,
  });
}
