import service from '@/utils/request/index'
import type { SurveySubmitData } from './types'
import type { UserLaunchCampaignStatusDataDto } from './types'

// 项目首次上线相关的活动接口

/**
 * 用户是否观看首页CG引导
 */
export const getUserLaunchCampaignStatus = () => {
  return service.request<UserLaunchCampaignStatusDataDto>({
    url: '/api/yaCulture/confirm/viewData',
    method: 'POST',
    data: {},
  })
}

/**
 * 标记用户已经观看过CG 或 普通动画引导
 */
export const markUserGuide = (pageKey: 'isView' | 'isViewGuide') => {
  return service.request({
    url: '/api/yaCulture/confirm/view',
    method: 'POST',
    data: { pageKey },
  })
}

/**
 * 用户点击相关奖励按钮 true: 第一次进入 跳出相关动画 false: 已经进入过 不跳出动画
 */
export const markUserClickedRewardButton = (pageKey: string) => {
  return service.request({
    url: '/api/yaCulture/first/view',
    method: 'POST',
    data: { pageKey },
  })
}

/**
 * 获取活动配置（双倍亚币、活动期间等）
 * TODO: 对接后端真实接口
 */
export const getActivityConfig = () => {
  return service.request({
    url: '/api/culture/activity/config',
    method: 'GET',
  })
}

/**
 * 获取CG引导观看状态
 * TODO: 对接后端真实接口
 */
export const getCgGuideStatus = () => {
  return service.request({
    url: '/api/culture/activity/cg-guide/status',
    method: 'GET',
  })
}

/**
 * 标记CG引导已观看 + 领取奖励（碎片+1, 亚币+2）
 * TODO: 对接后端真实接口
 */
export const completeCgGuide = () => {
  return service.request({
    url: '/api/culture/activity/cg-guide/complete',
    method: 'POST',
  })
}

/**
 * 领取碎片页面奖励（碎片+1, 亚币+2）
 * TODO: 对接后端真实接口
 */
export const claimFragmentReward = (pageKey: string) => {
  return service.request({
    url: '/api/culture/activity/fragment/claim',
    method: 'POST',
    data: { pageKey },
  })
}

/**
 * 获取碎片奖励状态（某页面是否已领取）
 * TODO: 对接后端真实接口
 */
export const getFragmentRewardStatus = (pageKey: string) => {
  return service.request({
    url: '/api/culture/activity/fragment/status',
    method: 'GET',
    params: { pageKey },
  })
}

/**
 * 获取满意度问卷配置
 * TODO: 对接后端真实接口
 */
export const getSurveyConfig = () => {
  return service.request({
    url: '/api/culture/activity/survey/config',
    method: 'GET',
  })
}

/**
 * 提交满意度问卷
 * TODO: 对接后端真实接口
 */
export const submitSurvey = (data: SurveySubmitData) => {
  return service.request({
    url: '/api/culture/activity/survey/submit',
    method: 'POST',
    data,
  })
}
