import { property } from "lodash";

export const sourceOptions: options[] = [
  { label: "桌面端", value: "pc" },
  { label: "管理端", value: "manager_app" },
  { label: "电话机点餐", value: "phone_book " },
];
export const typeOptions: options[] = [
  { label: "windows", value: "0" },
  { label: "安卓", value: "1" },
  { label: "IOS", value: "2" },
];
export const isForceOptions: options[] = [
  { label: "不强制更新", value: 0 },
  { label: "强制更新", value: 1 },
];

export type optionsType = "source" | "type" | "isForce";

export function returnOptions(type: optionsType) {
  if (type === "source") {
    return sourceOptions;
  }
  if (type === "type") {
    return typeOptions;
  }
  if (type === "isForce") {
    return isForceOptions;
  }
}

export function returnOptionsLabel(optionsType: optionsType, value: string | number) {
  const options = returnOptions(optionsType);
  if (!options) {
    return "";
  }
  const option = options.find((item) => item.value === value);
  return option ? option.label : "";
}

export interface options {
  label: string;
  value: string | number;
  [property: string]: any;
}
