import axios from './instance'
import { GET_SCENE_LIST } from './constant'
import type { PageResult, PageRequest } from './'
import { ui18n } from '@/lang'

export enum SceneStatus {
  DEL = -1,
  RUN = 0,
  ERR = 1,
  SUCCESS = 2,
  ARCHIVE = 3,
  RERUN = 4
}
export const sceneStatusDesc = {
  [SceneStatus.DEL]: ui18n.t('project.sceneDesc.DEL'),
  [SceneStatus.RUN]: ui18n.t('project.sceneDesc.RUN'),
  [SceneStatus.ERR]: ui18n.t('project.sceneDesc.ERR'),
  [SceneStatus.SUCCESS]: ui18n.t('project.sceneDesc.SUCCESS'),
  [SceneStatus.ARCHIVE]: ui18n.t('project.sceneDesc.ARCHIVE'),
  [SceneStatus.RERUN]: ui18n.t('project.sceneDesc.RERUN')
}

export enum SceneType {
  SWKK,
  SWKJ,
  SWSS,
  SWSG
}
export const SceneTypeDesc = {
  [SceneType.SWKK]: ui18n.t('project.sceneTypeDesc.SWKK'),
  [SceneType.SWKJ]: ui18n.t('project.sceneTypeDesc.SWKJ'),
  [SceneType.SWSS]: ui18n.t('project.sceneTypeDesc.SWSS'),
  [SceneType.SWSG]: ui18n.t('project.sceneTypeDesc.SWSG')
}

export interface Scene {
  id: number
  name: string
  num: string
  title: string
  sceneName: string
  thumb: string
  createTime: string
  type: SceneType
  status: SceneStatus
  shootCount: number
  phone: string
  bind: boolean
}

export type Scenes = Scene[]

export const fetchScenes = async (paging: PageRequest<{ type: SceneType }>) =>
  axios.post<PageResult<Scene>>(GET_SCENE_LIST, paging)
