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

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

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

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