Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 5x 57x 57x 32x 25x 12x 13x 8x 5x 3x 2x 175x 175x | import { cn } from "../../lib/utils";
type StatusVariant = "success" | "warning" | "error" | "info" | "default";
interface StatusBadgeProps {
status: string;
variant?: StatusVariant;
className?: string;
}
const variantStyles: Record<StatusVariant, string> = {
success: "bg-success-light text-success",
warning: "bg-warning-light text-warning",
error: "bg-error-light text-error",
info: "bg-info-light text-info",
default: "bg-background-muted text-foreground-muted",
};
/**
* Get the appropriate variant for common status values
*/
function getVariantForStatus(status: string): StatusVariant {
const statusLower = status.toLowerCase();
// Success states
if (
["published", "active", "converted", "verified", "ready"].includes(
statusLower,
)
) {
return "success";
}
// Warning states
if (
["draft", "pending", "contacted", "unverified", "expired"].includes(
statusLower,
)
) {
return "warning";
}
// Error states
if (
["archived", "banned", "closed", "rejected", "failed"].includes(
statusLower,
)
) {
return "error";
}
// Info states
if (["new", "processing"].includes(statusLower)) {
return "info";
}
return "default";
}
export function StatusBadge({ status, variant, className }: StatusBadgeProps) {
const computedVariant = variant || getVariantForStatus(status);
return (
<span
className={cn(
"inline-flex items-center px-2.5 py-0.5 text-xs font-semibold rounded-full",
variantStyles[computedVariant],
className,
)}
>
{status}
</span>
);
}
|