Files
ai-agent/web/app/dashboard/tickets/_components/ticket-status-badge.tsx
T

31 lines
1005 B
TypeScript
Raw Normal View History

2026-04-09 10:01:23 +08:00
"use client"
import { Badge } from "@/components/ui/badge"
2026-05-25 12:06:15 +08:00
import { useI18n } from "@/i18n/provider"
import type { TicketStatus } from "@/lib/api/ticket"
2026-04-09 10:01:23 +08:00
const statusMap = {
2026-05-25 12:06:15 +08:00
pending: { labelKey: "ticket.statusPending", className: "border-amber-200 bg-amber-50 text-amber-700" },
in_progress: { labelKey: "ticket.statusInProgress", className: "border-blue-200 bg-blue-50 text-blue-700" },
done: { labelKey: "ticket.statusDone", className: "border-emerald-200 bg-emerald-50 text-emerald-700" },
} as const
2026-04-09 10:01:23 +08:00
export function ticketStatusLabel(status: string) {
2026-05-25 12:06:15 +08:00
return status
2026-04-09 10:01:23 +08:00
}
export function getTicketStatusMeta(status: string) {
return statusMap[status as TicketStatus]
}
2026-04-09 10:01:23 +08:00
export function TicketStatusBadge({ status }: { status: string }) {
2026-05-25 12:06:15 +08:00
const t = useI18n()
const option = getTicketStatusMeta(status)
2026-04-09 10:01:23 +08:00
return (
<Badge variant="outline" className={option?.className ?? "border-border bg-muted text-muted-foreground"}>
2026-05-25 12:06:15 +08:00
{option ? t(option.labelKey) : status}
2026-04-09 10:01:23 +08:00
</Badge>
)
}