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

import { photosQueryKeys } from '../photos-query-keys';
import { photosApi } from '../photos-api';
import { ResponseType } from '../../response-type';

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

export const usePostDeletePhotoMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; photo_id: number },
    ResponseType
  >({
    mutationKey: photosQueryKeys.deletePhoto(),
    mutationFn: async (variables) => {
      const response = await photosApi.deletePhoto(variables.token, variables.photo_id);
      return response.data;
    }
  });
};
