import { get, post } from '../utils/http.js'

// 获取我邀请的BD列表
export const invitedList = async () => {
  try {
    const response = await get(`/team/bd/invite-bd-message-own`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my BD:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 邀请成为BD
export const inviteToBeBD = async (data) => {
  try {
    const response = await post(`/team/bd/invite-bd`, data)
    return response
  } catch (error) {
    console.error('Failed to invite to be BD:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 处理邀请(取消邀请)
export const cancelInvite = async (id) => {
  try {
    const response = await post(`/team/bd/invite-bd-cancel/${id}`)
    return response
  } catch (error) {
    console.error('Failed to cancel invite:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 查询BD Leader历史记录
export const getBdLeaderHistory = async () => {
  try {
    const response = await get(`/team/bd/leader/history`)
    return response
  } catch (error) {
    console.error('Failed to fetch BD leader history:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 查询BD Leader历史记录详情（More页面）
export const getBdLeaderHistoryMore = async (billBelong) => {
  try {
    const response = await get(`/team/bd/leader/history/more?billBelong=${billBelong}`)
    return response
  } catch (error) {
    console.error('Failed to fetch BD leader history more:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
