import { useMutation, UseMutationResult } from 'react-query';

import { uploadDigitalSignature } from 'src/services/forms';

type UploadSignatureParams = {
  image: string;
  signedUrl: string;
};

const useUploadSignature = (): UseMutationResult<
  string,
  unknown,
  UploadSignatureParams
> => {
  return useMutation({
    mutationFn: ({
      image,
      signedUrl,
    }: UploadSignatureParams): Promise<string> =>
      uploadDigitalSignature(image, signedUrl),
  });
};

export default useUploadSignature;
