File size: 2,420 Bytes
e9ce6e9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function formatMs(ms: number): string {
return `${Math.round(ms)}ms`;
}
export function formatPercent(value: number, max: number): string {
return `${Math.round((value / max) * 100)}%`;
}
export function getRiskColor(normalized: number): string {
if (normalized >= 0.8) return "#ef4444";
if (normalized >= 0.6) return "#f97316";
if (normalized >= 0.4) return "#f59e0b";
return "#22c55e";
}
export function getLatencyColor(ms: number): string {
if (ms > 800) return "#ef4444";
if (ms > 500) return "#f59e0b";
return "#22c55e";
}
export function getKafkaColor(lag: number): string {
if (lag > 4000) return "#ef4444";
if (lag > 3000) return "#f97316";
if (lag > 2000) return "#f59e0b";
return "#22c55e";
}
export function getBankStatusLabel(status: number): string {
return ["Healthy", "Degraded", "Unknown"][Math.round(status)] ?? "Unknown";
}
export function getBankStatusColor(status: number): string {
const s = Math.round(status);
if (s === 0) return "#22c55e";
if (s === 1) return "#f59e0b";
return "#ef4444";
}
export function getRiskDecisionLabel(d: number): string {
return ["Approve", "Reject", "Challenge"][d] ?? "?";
}
export function getCryptoVerifyLabel(v: number): string {
return ["FullVerify", "SkipVerify"][v] ?? "?";
}
export function getInfraRoutingLabel(r: number): string {
return ["Normal", "Throttle", "CircuitBreaker"][r] ?? "?";
}
export function getDbRetryLabel(d: number): string {
return ["FailFast", "ExpBackoff"][d] ?? "?";
}
export function getSettlementLabel(s: number): string {
return ["StandardSync", "DeferredAsync"][s] ?? "?";
}
export function getAppPriorityLabel(p: number): string {
return ["UPI", "Credit", "Balanced"][p] ?? "?";
}
export function getChannelLabel(c: number): string {
return ["P2P", "P2M", "AutoPay"][Math.round(c)] ?? "?";
}
export function getMerchantTierLabel(t: number): string {
return t >= 0.5 ? "Enterprise" : "Small";
}
export function generateActionLabel(action: {
risk_decision: number;
crypto_verify: number;
infra_routing: number;
}): string {
return `${getRiskDecisionLabel(action.risk_decision)} · ${getCryptoVerifyLabel(action.crypto_verify)} · ${getInfraRoutingLabel(action.infra_routing)}`;
}
|