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

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

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

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