import { post } from '@/core/http/http-client'
import { buildRestPath } from '@/core/config/api-paths'
import { normalizeRegion } from '@/features/passport/credential-bridge'

const ROUTE_DELETE_ACCOUNT = buildRestPath('user/deleteuser')
const ROUTE_RESET_SECRET = '/wanlshop/user/resetpwd'

/** 注销当前登录账号 */
export async function removeAccount() {
	return post(ROUTE_DELETE_ACCOUNT, {})
}

/** 短信验证码重置登录密码 */
export async function resetSecretBySms({ handset, region, passcode, secret, ticketId }) {
	return post(ROUTE_RESET_SECRET, {
		mobile: handset,
		area_code: normalizeRegion(region),
		captcha: passcode,
		newpassword: secret,
		message_id: ticketId || ''
	})
}
