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

import { photosQueryKeys } from '../photos-query-keys';
import { type PostSetSaveTempReturn, type PostSetUpdatePhoto, photosApi } from '../photos-api';

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

export const usePostUpdatePhotoMutation = () => {
  return useMutation<
    PostSetSaveTempReturn,
    BaseAxiosError,
    PostSetUpdatePhoto,
    PostSetSaveTempReturn
  >({
    mutationKey: photosQueryKeys.updatePhoto(),
    mutationFn: async (data) => {
      const response = await photosApi.updatePhoto(data);
      return response.data;
    }
  });
};
