import { request } from '@/utils/request'
import { Project } from '@/enums/api'
import {
  StartApplyReqParams,
  StartApplyResParams,
  NewPlanApplyReqParams,
  NewPlanApplyResParams,
  ModifyPlanApplyReqParams,
  ModifyPlanApplyResParams,
  CancelApplyReqParams
} from '@/types/apply'

/**
 * 申请立项
 * @param params StartApplyReqParams
 * @returns
 */
export const startApplyProject = (params: StartApplyReqParams) => {
  return request.post<StartApplyResParams>({
    url: Project.PROJECT_APPLY_START,
    data: params
  })
}

/**
 * 申请审核新建任务计划
 * @param params NewPlanApplyReqParams
 * @returns
 */
export const newPlanApplyProject = (params: NewPlanApplyReqParams) => {
  return request.post<NewPlanApplyResParams>({
    url: Project.PROJECT_APPLY_NEW_PLAN,
    data: params
  })
}

/**
 * 申请变更任务计划
 * @param params ModifyPlanApplyReqParams
 * @returns
 */
export const modifyPlanApplyProject = (params: ModifyPlanApplyReqParams) => {
  return request.post<ModifyPlanApplyResParams>({
    url: Project.PROJECT_APPLY_MODIFY_PLAN,
    data: params
  })
}

/**
 * 撤回申请
 * @param params CancelApplyReqParams
 * @returns
 */
export const cancelApplyProject = (params: CancelApplyReqParams) => {
  return request.post<BaseResParams>({
    url: Project.PROJECT_APPLY_CANCEL,
    data: params
  })
}
