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

// 获取排行榜和我的排名
export const getRankingListAndMyRanking = async (data) => {
  try {
    const response = await post(`/ranking/list`, data)
    return response
  } catch (error) {
    console.error('Failed to get list and my ranking:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取本周奖励和礼物
export const getThisWeekRewardsAndGifts = async (templateId) => {
  try {
    const response = await get(`/activity/king-queen/effective?templateId=${templateId}`)
    return response
  } catch (error) {
    console.error('Failed to get this week rewards and gifts:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取总榜前三
export const getOverallRankingTop3 = async (data) => {
  try {
    const response = await post(`/ranking/top-three-overall`, data)
    return response
  } catch (error) {
    console.error('Failed to get history top one:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取总榜
export const getOverallRanking = async (topN, data) => {
  try {
    const response = await post(`/ranking/top-three-overall?topN=${topN}`, data)
    return response
  } catch (error) {
    console.error('Failed to get history top one:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取历史榜首
export const getHistoryTopOne = async (activityType) => {
  try {
    let data = { activityType }
    const response = await post(`/ranking/historical-top1`, data)
    return response
  } catch (error) {
    console.error('Failed to get history top one:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取指定类型活动资源
export const activityResource = async (data) => {
  try {
    const response = await get(
      `/props-activity-cnf/client/listActivityResource?sysOrigin=${data.sysOrigin}&activityType=${data.activityType}`,
    )
    return response
  } catch (error) {
    console.error('Failed to get this week rewards and gifts:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
