import http from '@/utils/http'
import { AppDispatch } from '..'
import { A5AddType } from '@/types/api/A5activity'

/**
 * 活动-删除
 */
export const A5_APIdel = (id: number) => {
  return http.post(`museum/activity/del/${id}`)
}

/**
 * 活动-获取详情
 */
export const A5_APIgetInfo = (id: number) => {
  return http.post(`museum/activity/info/${id}`)
}

/**
 * 活动 新增
 */
export const A5_APIadd = (data: A5AddType) => {
  return http.post('museum/activity/add', data)
}

/**
 * 活动 修改
 */
export const A5_APIedit = (data: A5AddType) => {
  return http.post('museum/activity/edit', data)
}

/**
 * 活动-发布
 */
export const A5_APIpublish = (id: number) => {
  return http.post(`museum/activity/publish`, { activityId: id })
}

/**
 * 活动-列表
 */
export const A5_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('museum/activity/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: 'A5/getList', payload: obj })
    }
  }
}
