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

import { eventsQueryKeys } from '../events-query-keys';
import { eventsApi, type PostGetEventForEditingReturn } from '../events-api';

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

export const useGetSharedTripForEditingMutation = () => {
  return useMutation<
    PostGetEventForEditingReturn,
    BaseAxiosError,
    { token: string; event_id: number },
    PostGetEventForEditingReturn
  >({
    mutationKey: eventsQueryKeys.getSharedTripForEditing(),
    mutationFn: async (data) => {
      const response = await eventsApi.getSharedTripForEditing(data.token, data.event_id);
      return response.data;
    }
  });
};
