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

// 获取财富榜
export const getWealthRanking = async () => {
  try {
    const response = await get(`/activity/leaderboard/gifts-send`)
    return response
  } catch (error) {
    console.error('Failed to fetch get wealth ranking:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取魅力榜
export const getCharmRanking = async () => {
  try {
    const response = await get(`/activity/leaderboard/gifts-received`)
    return response
  } catch (error) {
    console.error('Failed to fetch get charm ranking:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取房间榜
export const getRoomRanking = async () => {
  try {
    const response = await get(`/activity/leaderboard/room-gifts`)
    return response
  } catch (error) {
    console.error('Failed to fetch get room ranking:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取我的排名
export const getMyRanking = async (type, dateType) => {
  try {
    const response = await get(`/activity/leaderboard/my-rank?type=${type}&dateType=${dateType}`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my ranking:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取房间贡献总榜
export const getRoomContributionTotalRank = async (data) => {
  try {
    const response = await get(
      `/room/contribution/total-rank?startDate=${data.startDate}&endDate=${data.endDate}&size=${data.size}`,
    )
    return response
  } catch (error) {
    console.error('Failed to fetch room contribution total rank:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
