import Vue from "vue";
import { dateFormatForAPI } from "@/utils/utils";
import { APPROVE_STATUS } from "@/constant/constants";

Vue.filter("booleanYesNoFilter", function (val) {
  if (val === null) return "无";
  return { true: "是", false: "否" }[val];
});

Vue.filter("booleanEnableDisableFilter", function (val) {
  if (val === null) return "无";
  return { true: "启用", false: "禁用" }[val];
});

Vue.filter("booleanPassFilter", function (val) {
  if (val === null) return "无";
  return { true: "通过", false: "不通过" }[val];
});

Vue.filter("zeroOneYesNoFilter", function (val) {
  if (val === null) return "无";
  return { 1: "是", 0: "否" }[val];
});

Vue.filter("zeroOneEnableDisableFilter", function (val) {
  if (val === null) return "无";
  return { 1: "启用", 0: "禁用" }[val];
});

Vue.filter("zeroOnePassFilter", function (val) {
  if (val === null) return "无";
  return { 1: "通过", 0: "不通过" }[val];
});

Vue.filter("datetimeFilter", function (val) {
  if (val === null) return "";
  return dateFormatForAPI(val);
});

Vue.filter("scoreStatusFilter", function (val) {
  if (val === null) return "无";
  return {
    NEVER: "从未算分",
    CALCULATING: "正在算分",
    FINISH: "算分完成",
  }[val];
});

Vue.filter("modeFilter", function (val) {
  if (val === null) return "无";
  return { TOGETHER: "集中统一", ANYTIME: "随到随考" }[val];
});

Vue.filter("monitorStatusFilter", function (val) {
  if (val === null) return "无";
  return { NOT_START: "未开始", START: "监考中", FINISHED: "已结束" }[val];
});

Vue.filter("zeroOneApproveStatusFilter", function (val) {
  if (val === null) return "";
  return APPROVE_STATUS[val];
});
