/**
 * 线索记录-列表
 */

import http from '@/utils/http'
import { AppDispatch } from '@/store'
import { ClueItem } from '@/types/api/clue'

/**
 * 获取线索记录列表
 */
type Clue_APIgetClueListParams = {
  martyrId?: number
  pageNum: number
  pageSize: number
  searchKey?: string
  status?: number
  type?: string
}
export const Clue_APIgetClueList = (data: Clue_APIgetClueListParams): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('show/clue/pageList', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records.map((item: ClueItem) => ({
          ...item,
          status: {
            0: '待确定',
            1: '跟进中',
            2: '已找到',
            3: '未找到',
            4: '作废'
          }[item.status] as string
        })),
        total: res.data.total
      }

      dispatch({ type: 'Clue_APIgetClueList', payload: obj })
    }
  }
}

export const getTopinfo = () => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get('/show/maintain/detail/10')
    if (res.code === 0) {
      return res.data
    }
  }
}
