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

import { authQueryKeys } from '../auth-query-keys';
import { authApi, type UserResetPasswordReturn } from '../auth-api';

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

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;
    }
  });
};
