Files
germantax-e2e-mrg0vbxr/packages/components/src/status-badge.tsx
2026-07-11 09:07:34 +02:00

34 lines
768 B
TypeScript

import { Badge } from '@pikku/mantine/core'
import { asI18n } from '@pikku/react'
const STATUS_COLORS: Record<string, string> = {
draft: 'gray',
pending: 'yellow',
in_review: 'orange',
under_review: 'orange',
approved: 'blue',
active: 'green',
open: 'green',
filed: 'green',
completed: 'gray',
archived: 'gray',
closed: 'gray',
rejected: 'red',
overdue: 'red',
cancelled: 'red',
}
function formatStatus(status: string): string {
return status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
}
export function StatusBadge({ status }: { status: string }) {
const color = STATUS_COLORS[status] ?? 'gray'
return (
<Badge color={color} variant="light" size="sm">
{asI18n(formatStatus(status))}
</Badge>
)
}