import { createCrudApi } from './common';
import request from '@/axios';

const baseUrl = '/blade-transport/project-apply';
const api = createCrudApi(baseUrl);

export const getList = api.getList;
export const getDetail = api.getDetail;
export const submit = api.submit;
export const remove = api.remove;

export const saveDraft = row =>
  request({
    url: `${baseUrl}/save-draft`,
    method: 'post',
    data: row,
  });

export const submitApproval = id =>
  request({
    url: `${baseUrl}/submit-approval`,
    method: 'post',
    params: { id },
  });

export const approve = id =>
  request({
    url: `${baseUrl}/approve`,
    method: 'post',
    params: { id },
  });

export const reject = id =>
  request({
    url: `${baseUrl}/reject`,
    method: 'post',
    params: { id },
  });

export const withdraw = id =>
  request({
    url: `${baseUrl}/withdraw`,
    method: 'post',
    params: { id },
  });

export const voidProject = (id, reason) =>
  request({
    url: `${baseUrl}/void`,
    method: 'post',
    params: { id, reason },
  });

export const saveChange = row =>
  request({
    url: `${baseUrl}/save-change`,
    method: 'post',
    data: row,
  });

export const submitChange = row =>
  request({
    url: `${baseUrl}/submit-change`,
    method: 'post',
    data: row,
  });

export const startChange = (id, reason) =>
  request({
    url: `${baseUrl}/start-change`,
    method: 'post',
    params: {
      id,
      changeContent: reason,
      changeReason: reason,
    },
  });
