import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode, Result } from '/#/axios';
import {
  ArbitrationCloseData,
  ArbitrationCommitParams,
  ArbitrationData,
  ArbitrationParams,
} from '/@/api/arbitration/model/arbitrationModel';

enum Api {
  List = '/arbitrate/list',
  Detail = '/arbitrate/detail',
  Commit = '/arbitrate/commit',
  Logs = '/arbitrate/logs',
  Nums = '/arbitrate/nums',
}

/**
 * @description: 仲裁列表
 */
export function arbitrateListApi(data: ArbitrationParams, mode: ErrorMessageMode = 'message') {
  return defHttp.post<ArbitrationData[]>(
    {
      url: Api.List,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 处理仲裁
 */
export function arbitrateCommitApi(
  data: ArbitrationCommitParams,
  mode: ErrorMessageMode = 'message',
) {
  return defHttp.post<Result<null>>(
    {
      url: Api.Commit,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 仲裁详情
 */
export function arbitrateDetailApi(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.get<ArbitrationData>(
    {
      url: `${Api.Detail}/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 对应仲裁的操作记录
 */
export function arbitrateLogsApi(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.post<ArbitrationCloseData[]>(
    {
      url: `${Api.Logs}/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 对应仲裁的状态的数量
 */
export function arbitrateNumsApi(_: any = undefined, mode: ErrorMessageMode = 'message') {
  return defHttp.post<ArbitrationCloseData[]>(
    {
      url: Api.Nums,
    },
    {
      errorMessageMode: mode,
    },
  );
}
