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

// 获取国王/女王榜单
export const getWeekTopList = async (data) => {
  try {
    const response = await get(
      `/activity/king-queen/ranking?type=${data.type}&kingQueenType=${data.kingQueenType}&current=${data.current}&size=${data.size}`
    )
    return response
  } catch (error) {
    console.error('Failed to get week top list:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取我本周贡献
export const getWeekMyContribution = async (userId) => {
  try {
    const response = await get(`/activity/king-queen/user-contribute?userId=${userId}`)
    return response
  } catch (error) {
    console.error('Failed to get week my contribution:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取本周奖励和礼物
export const getThisWeekRewardsAndGifts = async (activityId) => {
  try {
    const response = await get(`/activity/king-queen/effective?templateId=${activityId}`)
    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 getHistoryTopOne = async () => {
  try {
    const response = await get(`/activity/king-queen/history`)
    return response
  } catch (error) {
    console.error('Failed to get history top one:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
