import http from '@/utils/http'
import { AppDispatch } from '..'
import { A1tableType } from '@/pages/A1list/type'

/**
 * 展馆预约记录-列表
 */

export const A1_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/applyExhibition/pageList', data)
    if (res.code === 0) {
      const arr: A1tableType[] = res.data.records
      arr.forEach(v => {
        v.cityStr = v.province + '-' + v.city
      })

      const obj = {
        list: arr,
        total: res.data.total
      }
      dispatch({ type: 'A1/getList', payload: obj })
    }
  }
}

/**
 * 展馆预约记录-核销
 */
export const A1_APIupdate = (id: number, status: 0 | 1) => {
  return http.get(`cms/applyExhibition/update/${id}/${status}`)
}

/**
 * 展馆预约记录-详情
 */
export const A1_APIgetInfo = (id: number) => {
  return http.get(`cms/applyExhibition/detail/${id}`)
}

/**
 * 检查token
 */
export const A1_APIcheckToken = () => {
  return http.get('admin/checkLogin')
}
