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

import { tripsQueryKeys } from '../trips-query-keys';
import { tripsApi, type PostGetRegionsThatHaveTripsReturn } from '../trips-api';

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

export const useGetRegionsThatHaveTripsQuery = (enabled: boolean) => {
  return useQuery<PostGetRegionsThatHaveTripsReturn, BaseAxiosError>({
    queryKey: tripsQueryKeys.getRegionsThatHaveTrips(),
    queryFn: async () => {
      const response = await tripsApi.getRegionsThatHaveTrips();
      return response.data;
    },
    enabled
  });
};
