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

import { travelsQueryKeys } from '../travels-query-keys';
import { travelsApi, type PostGetKyeReturn } from '../travels-api';

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

export const useGetKyeQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetKyeReturn, BaseAxiosError>({
    queryKey: travelsQueryKeys.getKye(token),
    queryFn: async () => {
      const response = await travelsApi.getKye(token);
      return response.data;
    },
    enabled
  });
};
