import obj from '@/utils/obj'

export type SetTargetDataItem = {
  id: any
  name: string
}

export type SetTargetData = {
  classes: SetTargetDataItem[]
  students: SetTargetDataItem[]
}

// 任务主题
export const topic_free_learn = 'free_learn'
export const topic_word_mastery = 'word_mastery'
export const topic_word_quest = 'word_quest'
export const topic_word_review = 'word_review'
export const topic_sentence_training = 'sentence_training'
export const topicTypeCodeMap = {
  [topic_word_mastery]: '单词掌握',
  [topic_word_review]: '单词复习',
  [topic_word_quest]: '单词闯关',
  [topic_sentence_training]: '句子训练',
  [topic_free_learn]: '自由学',
} as any
export const topicTypeCodeOptions = obj.map2options(topicTypeCodeMap)
export const topicTypeCodeOptions2 = topicTypeCodeOptions.filter(
  (item: any) => item.value !== topic_word_review,
)

// 任务优先级
export const task_priority_normal = 0
export const task_priority_middle = 1
export const task_priority_high = 2
export const task_priority_map = {
  [task_priority_normal]: '普通',
  [task_priority_middle]: '中',
  [task_priority_high]: '高',
} as any
export const task_priority_options = obj.map2options(task_priority_map)

// 任务状态
export const task_status_unpublished = 0
export const task_status_ready = 1
export const task_status_ing = 2
export const task_status_canceled = 3
export const task_status_finished = 4
export const task_status_map = {
  [task_status_unpublished]: '待发布',
  [task_status_ready]: '待开始',
  [task_status_ing]: '执行中',
  [task_status_canceled]: '被取消',
  [task_status_finished]: '已完成',
} as any

// 用户任务 0 未开始, 1 执行中 2 完成 3 未完成
export const user_task_status_unpublished = 0
export const user_task_status_ing = 1
export const user_task_status_finished = 2
export const user_task_status_unfinished = 3
export const user_task_status_canceled = 4
export const user_task_status_map = {
  [user_task_status_unpublished]: '待开始',
  [user_task_status_ing]: '执行中',
  [user_task_status_finished]: '已完成',
  [user_task_status_unfinished]: '未完成',
  [user_task_status_canceled]: '被取消',
} as any

export function getTaskStatusClass(status: any) {
  switch (Number(status)) {
    case task_status_canceled:
      return 'task-canceled'
    case task_status_ready:
      return 'task-ready'
    case task_status_finished:
      return 'task-finished'
    case task_status_ing:
      return 'tasking'
    case task_status_unpublished:
      return 'task-unpublished'
  }
}

export function getUserStatusClass(status: any) {
  switch (Number(status)) {
    case user_task_status_unfinished:
      return 'task-unfinished'
    case user_task_status_canceled:
      return 'task-canceled'
    case user_task_status_finished:
      return 'task-finished'
    case user_task_status_ing:
      return 'tasking'
    case user_task_status_unpublished:
      return 'task-ready'
  }
}
