StatusBadge.tsx
743 Bytes
import { useT } from '@/i18n/LocaleContext'
import type { MessageKey } from '@/i18n/messages'
interface Props {
status: string
}
const CLS_MAP: Record<string, string> = {
DRAFT: 'badge-draft',
CONFIRMED: 'badge-confirmed',
SHIPPED: 'badge-shipped',
RECEIVED: 'badge-received',
COMPLETED: 'badge-completed',
CANCELLED: 'badge-cancelled',
IN_PROGRESS: 'badge-in-progress',
PENDING: 'badge-pending',
POSTED: 'badge-confirmed',
SETTLED: 'badge-shipped',
REVERSED: 'badge-cancelled',
}
export function StatusBadge({ status }: Props) {
const t = useT()
const cls = CLS_MAP[status] ?? 'badge-pending'
const key = `status.${status}` as MessageKey
const label = t(key)
return <span className={cls}>{label}</span>
}