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

import { locationQueryKeys } from '../location-query-keys';
import { locationApi, type PostGetSettingsReturn } from '../location-api';

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

export const usePostGetSettingsQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetSettingsReturn, BaseAxiosError>({
    queryKey: locationQueryKeys.getSettings(token),
    queryFn: async () => {
      const response = await locationApi.getSettings(token);
      return response.data;
    },
    enabled
  });
};
