'use server'
import {callByUser, callPublic} from '@/actions/base'

export async function RechargePrepare(props: {
  amount: number
  platform: number
  method: number
}) {
  return callByUser<{
    trade_no: string
    pay_url: string
  }>('/api/trade/create', {
    platform: props.platform,
    method: props.method,
    type: 2,
    recharge: {
      amount: props.amount,
    },
  })
}

export async function RechargeComplete(props: {
  trade_no: string
  method: number
}) {
  return callByUser('/api/trade/complete', props)
}

export async function Identify(props: {
  type: number
  name: string
  iden_no: string
}) {
  return await callByUser<{
    identified: boolean
    target: string
  }>('/api/user/identify', props)
}

export async function update(props: {
  username: string
  email: string
  contact_qq: string
  contact_wechat: string
}) {
  return await callByUser('/api/user/update', props)
}

export async function updatePassword(props: {
  phone: string
  code: string
  password: string
}) {
  return await callByUser('/api/user/update/password', props)
}
