import type { DictData } from "../../api/crm";

export function dictOptions(dicts: DictData[], type: string) {
  return dicts.filter(item => item.dictType === type && item.status !== 1).sort((a, b) => Number(a.sort || 0) - Number(b.sort || 0));
}
export function dictLabel(dicts: DictData[], type: string, value?: string | number, fallback = "--") {
  return dicts.find(item => item.dictType === type && String(item.value) === String(value))?.label || fallback;
}
export function statusText(status?: number) { return Number(status) === 1 ? "禁用" : "开启"; }
export function statusClass(status?: number) { return Number(status) === 1 ? "tag-off" : "tag-on"; }
export function dateText(value?: string) { return value ? value.replace("T", " ").slice(0, 19) : "--"; }
