import { useQuery } from '@tanstack/react-query';

import { notificationsQueryKeys } from '../notifications-query-keys';
import { notificationsApi, type PostGetSettings } from '../notifications-api';

import type { BaseAxiosError } from '../../../../types';

export const useGetSettingsQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetSettings, BaseAxiosError>({
    queryKey: notificationsQueryKeys.getSettings(token),
    queryFn: async () => {
      const response = await notificationsApi.getSettings(token);
      return response.data;
    },
    enabled
  });
};
