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

export enum SceneStatus {
  DEL = -1,
  RUN = 0,
  ERR = 1,
  SUCCESS = 2,
  ARCHIVE = 3,
  RERUN = 4
}
export const sceneStatusDesc = {
  [SceneStatus.DEL]: '场景被删',
  [SceneStatus.RUN]: '计算中',
  [SceneStatus.ERR]: '计算失败',
  [SceneStatus.SUCCESS]: '计算成功',
  [SceneStatus.ARCHIVE]: '封存',
  [SceneStatus.RERUN]: '重新计算中'
}

export enum SceneType {
  SWKK,
  SWKJ,
  SWSS
}
export const SceneTypeDesc = {
  [SceneType.SWKK]: '四维看看',
  [SceneType.SWKJ]: '四维看见',
  [SceneType.SWSS]: '四维深时'
}

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

export type Scenes = Scene[]

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