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

// 每日签到奖励列表.
export const apiGetLoginRewards = async (activityType) => {
  try {
    const response = await get(`/task/check/in/list/award?activityType=${activityType}`)
    return response
  } catch (error) {
    console.error('Failed to get login rewards:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 今天是否已签到.
export const apiGetTodayLoginStatus = async (dailyKey) => {
  try {
    const response = await get(`/task/check/in/today?dailyKey=${dailyKey}`)
    return response
  } catch (error) {
    console.error('Failed to get today login info:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 打卡-领取奖励.
export const postReceiveLoginReward = async (data) => {
  try {
    const response = await post(`/task/check/in/receive`, data)
    return response
  } catch (error) {
    console.error('Failed to post receive login reward:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
