import http from '@/utils/http'
import { AppDispatch } from '..'

/**
 * 认证邀请码-列表
 */

export const A61_APIgetList = (data: any, type: 'live' | 'neighbour'): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/invitation/pageList', { ...data, type })
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: type === 'live' ? 'A61/getList1' : 'A61/getList2', payload: obj })
    }
  }
}

/**
 * 认证邀请码-删除
 */
export const A61_APIdel = (id: number) => {
  return http.get(`cms/invitation/removes/${id}`)
}

/**
 * 认证邀请码-获取随机码
 */
export const A61_APIgetCode = () => {
  return http.get('cms/invitation/getCode')
}

/**
 * 认证邀请码-新增
 */
export const A61_APIsave = (data: any) => {
  return http.post('cms/invitation/add', data)
}
