import axios from "../../../config/axios";
import {
  type ApiResponse,
  type CheckHasAccountType,
  type LoginWithPasswordType,
  type RefreshTokenResponse,
  type RefreshTokenType,
  type RegisterType,
} from "../types/AuthTypes";

export const loginWithPassword = async (params: LoginWithPasswordType) => {
  const { data } = await axios.post(`/admin/login/password`, params);
  return data;
};

export const checkHasAccount = async (params: CheckHasAccountType) => {
  const { data } = await axios.post(`/auth/check`, params);
  return data;
};

export const register = async (params: RegisterType) => {
  const { data } = await axios.post(`/auth/register/complete`, params);
  return data;
};

export const refreshToken = async (
  params: RefreshTokenType
): Promise<ApiResponse<RefreshTokenResponse>> => {
  const { data } = await axios.post(`/user/token`, params);
  return data;
};

