import type { ReactNode } from "react"; import { cn } from "@/lib/utils"; import type { ColumnFormat } from "@/pages/ruleEngine/config/resources"; import { Badge } from "@edr/ui-common"; const statusBadgeClass = (active: boolean) => cn( "rounded-sm px-2 py-0.5 text-xs font-medium", active ? "border-emerald-200 bg-emerald-50 text-emerald-800" : "border-border bg-muted text-muted-foreground", ); export const formatCell = (value: unknown, format?: ColumnFormat): ReactNode => { if (value === null || value === undefined || value === "") { return ; } if (format === "boolean") { return value ? "Yes" : "No"; } if (format === "activeBadge") { const active = Boolean(value); return ( {active ? "Active" : "Inactive"} ); } if (format === "rateStatus") { const status = String(value); const tone = status === "LIVE" ? "border-emerald-200 bg-emerald-50 text-emerald-800" : status === "DRAFT" ? "border-amber-200 bg-amber-50 text-amber-800" : "border-sky-200 bg-sky-50 text-sky-800"; return ( {status} ); } if (format === "code") { return ( {String(value)} ); } if (format === "date") { const d = new Date(String(value)); return Number.isNaN(d.getTime()) ? String(value) : d.toLocaleDateString(); } return String(value); };