import { queryOptions } from '@tanstack/react-query';
import { getNotifications, getUnreadNotificationCount } from './service';
import type { NotificationFilters } from './types';

export const notificationKeys = {
  all: ['notifications'] as const,
  lists: () => [...notificationKeys.all, 'list'] as const,
  list: (filters: NotificationFilters) => [...notificationKeys.lists(), filters] as const,
  unreadCount: () => [...notificationKeys.all, 'unread-count'] as const
};

export const notificationsQueryOptions = (filters: NotificationFilters = {}) =>
  queryOptions({
    queryKey: notificationKeys.list(filters),
    queryFn: () => getNotifications(filters)
  });

export const notificationUnreadCountQueryOptions = () =>
  queryOptions({
    queryKey: notificationKeys.unreadCount(),
    queryFn: () => getUnreadNotificationCount()
  });
