import { useMutation } from '@tanstack/react-query';
import { authApi, UserResetPasswordReturn } from '../auth-api';
import { BaseAxiosError } from '../../../../types';
import { authQueryKeys } from '../auth-query-keys';

export type UserResetPasswordData = {
  email: string;
};

export const useResetPasswordMutation = () => {
  return useMutation<
    UserResetPasswordReturn,
    BaseAxiosError,
    UserResetPasswordData,
    UserResetPasswordReturn
  >({
    mutationKey: authQueryKeys.resetPassword(),
    mutationFn: async (data) => {
      const response = await authApi.resetPassword(data);
      return response.data;
    }
  });
};
