import { withResolvers } from "../promise"

export function login(timeout?: number) {
  const { promise, resolve, reject } = withResolvers<WechatMiniprogram.LoginSuccessCallbackResult>();
  wx.login({ timeout, success: resolve, fail: reject, });
  return promise;
}

export function getPrivacySetting() {
  const { promise, resolve, reject } = withResolvers<WechatMiniprogram.GetPrivacySettingSuccessCallbackResult>();
  wx.getPrivacySetting({ success: resolve, fail: reject });
  return promise;
}

export function openPrivacyContract() {
  const { promise, resolve, reject } = withResolvers<WechatMiniprogram.GeneralCallbackResult>();
  wx.openPrivacyContract({ success: resolve, fail: reject });
  return promise;
}