import { useMyRequest } from '~/composables/useFetchRequest'

enum Api {
  Login = '/client/user/login',
  UserInfo = '/client/user/userinfo',
  Logout = '/client/user/logout',
  Register = '/client/user/preRegister',
  ValidateRegister = '/client/user/register',
  ValidateEmail = '/client/user/forgetPassword',
  ResetOrChangePassword = '/client/user/changePassword',
}

/**
 * @description: user login api
 */
export async function loginApi(params: any) {
  return await useMyRequest().post(Api.Login, params)
}
/**
 * 预注册
 * @param params
 * @param mode
 * @returns
 */
export async function registerApi(params: any) {
  return await useMyRequest().post(Api.Register, params)
}
/**
 * 注册
 * @param params
 * @returns
 */
export async function validateRegisterApi(params: any) {
  return await useMyRequest().post(Api.ValidateRegister, params)
}
/**
 * 忘记密码，发送邮箱
 * @param params
 * @returns
 */
export async function validateEmailApi(params: any) {
  return await useMyRequest().post(Api.ValidateEmail, params)
}
/**
 * 更新用户信息
 * @param params
 * @returns
 */
export async function updateUserInfoApi(params: any) {
  return await useMyRequest().post(Api.UserInfo, params)
}
/**
 * 重置密码
 * @param params
 * @returns
 */
export async function resetOrChangePasswordApi(params: any) {
  return await useMyRequest().post(Api.ResetOrChangePassword, params)
}
/**
 * @description: getUserInfo
 */
export async function getUserProfileApi() {
  return await useMyRequest().get(Api.UserInfo)
}

export async function logoutApi() {
  return await useMyRequest().get(Api.Logout)
}
