import type { ReactNode } from 'react' import { cx } from './cx' export type StatusHue = 'amber' | 'blue' | 'violet' | 'orange' | 'indigo' | 'green' | 'grey' | 'red' const HUES: Record = { reported: 'amber', triaged: 'blue', investigating: 'violet', capa_pending: 'orange', verification: 'indigo', closed: 'green', open: 'grey', in_progress: 'blue', overdue: 'red', pending_verification: 'indigo', verified: 'green', reopened: 'red', critical: 'red', high: 'orange', med: 'amber', medium: 'amber', low: 'grey', active: 'green', } const LABELS: Record = { capa_pending: 'CAPA pending', pending_verification: 'Verification', in_progress: 'In progress', med: 'Medium', } // Full literal class strings so Tailwind can see them. const HUE_CLASS: Record = { amber: 'bg-st-amber-bg text-st-amber-fg', blue: 'bg-st-blue-bg text-st-blue-fg', violet: 'bg-st-violet-bg text-st-violet-fg', orange: 'bg-st-orange-bg text-st-orange-fg', indigo: 'bg-st-indigo-bg text-st-indigo-fg', green: 'bg-st-green-bg text-st-green-fg', grey: 'bg-st-grey-bg text-st-grey-fg', red: 'bg-st-red-bg text-st-red-fg', } export function statusHue(key: string): StatusHue { return HUES[key] ?? 'grey' } function label(key: string): string { if (LABELS[key]) return LABELS[key] const words = key.split('_').join(' ') return words.charAt(0).toUpperCase() + words.slice(1) } function Pill({ hue, className, children }: { hue: StatusHue; className?: string; children: ReactNode }) { return ( {children} ) } export function StatusTag({ status, children }: { status: string; children?: ReactNode }) { return {children ?? label(status)} } export function PriorityTag({ priority, children }: { priority: string; children?: ReactNode }) { return {children ?? label(priority)} }