/** * ReliabilityStatusBadge Component * * Badge component for visualizing PageAnalysis reliability status. * Color-coded badges with icons for each status type. * * Status colors: * - DRAFT: Gray * - PENDING_CONFIRMATION: Yellow * - CONFIRMED: Green * - REJECTED: Red * * @layer UI */ import * as React from 'react'; import { CheckCircle2, Clock, XCircle, FileQuestion } from 'lucide-react'; import { ReliabilityStatus } from '@archer/domain'; import { cn } from '@/lib/utils'; export interface ReliabilityStatusBadgeProps { status: ReliabilityStatus; size?: 'sm' | 'md' | 'lg'; showIcon?: boolean; className?: string; } interface StatusConfig { label: string; icon: React.ComponentType<{ className?: string }>; bgColor: string; textColor: string; borderColor: string; } const STATUS_CONFIG: Record = { [ReliabilityStatus.DRAFT]: { label: 'Draft', icon: FileQuestion, bgColor: 'bg-gray-100', textColor: 'text-gray-700', borderColor: 'border-gray-300', }, [ReliabilityStatus.PENDING_CONFIRMATION]: { label: 'Pending', icon: Clock, bgColor: 'bg-yellow-100', textColor: 'text-yellow-700', borderColor: 'border-yellow-300', }, [ReliabilityStatus.CONFIRMED]: { label: 'Confirmed', icon: CheckCircle2, bgColor: 'bg-green-100', textColor: 'text-green-700', borderColor: 'border-green-300', }, [ReliabilityStatus.REJECTED]: { label: 'Rejected', icon: XCircle, bgColor: 'bg-red-100', textColor: 'text-red-700', borderColor: 'border-red-300', }, }; const SIZE_CLASSES = { sm: { container: 'px-2 py-0.5 text-xs', icon: 'h-3 w-3', }, md: { container: 'px-2.5 py-1 text-sm', icon: 'h-4 w-4', }, lg: { container: 'px-3 py-1.5 text-base', icon: 'h-5 w-5', }, }; export const ReliabilityStatusBadge = React.forwardRef( ({ status, size = 'md', showIcon = true, className }, ref) => { const config = STATUS_CONFIG[status]; const sizeClasses = SIZE_CLASSES[size]; if (!config) { // Handle unknown status gracefully return (
Unknown
); } const Icon = config.icon; return (
{showIcon &&
); } ); ReliabilityStatusBadge.displayName = 'ReliabilityStatusBadge';