import recordAxiosInstance from "@/shared/services/recordAxiosInstance";
import Cookies from "js-cookie";
import { withHeaders } from "./withHeaders";

interface ChangePasswordDto {
  email: string;
  verificationCode: string;
  newPassword: string;
  confirmPassword: string;
}

export const changePassword = async (data: ChangePasswordDto): Promise<any> => {
  try {
    const { data: responseData } = await recordAxiosInstance.patch(
      "auth/change-password",
      data,
      {
        headers: withHeaders(),
      }
    );

    return responseData;
  } catch (error) {
    throw error;
  }
};

export const requestPasswordReset = async (email: string): Promise<any> => {
  try {
    const { data } = await recordAxiosInstance.post(
      "auth/forgot-password",
      { email },
      {
        headers: withHeaders(),
      }
    );

    return data;
  } catch (error) {
    throw error;
  }
};
