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

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

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostAddSharedTripMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostAddSharedTrip, ResponseType>({
    mutationKey: eventsQueryKeys.addSharedTrip(),
    mutationFn: async (data) => {
      const response = await eventsApi.addSharedTrip(data);
      return response.data;
    }
  });
};
