sing-ui/components/status-badge.tsx

41 lines
1.1 KiB
TypeScript

import { Badge } from "@/components/ui/badge";
import { cn } from "@/lib/utils";
const CONFIG: Record<string, { label: string; className: string }> = {
running: {
label: "运行中",
className: "border-blue-500/40 bg-blue-500/10 text-blue-600 dark:text-blue-400",
},
success: {
label: "成功",
className:
"border-green-500/40 bg-green-500/10 text-green-600 dark:text-green-400",
},
failed: {
label: "失败",
className: "border-red-500/40 bg-red-500/10 text-red-600 dark:text-red-400",
},
cancelled: {
label: "已取消",
className:
"border-yellow-500/40 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",
},
queued: {
label: "排队中",
className:
"border-zinc-500/40 bg-zinc-500/10 text-zinc-600 dark:text-zinc-400",
},
};
export function StatusBadge({ status }: { status: string }) {
const c = CONFIG[status] ?? {
label: status,
className: "border-border text-muted-foreground",
};
return (
<Badge variant="outline" className={cn(c.className)}>
{c.label}
</Badge>
);
}