import * as React from "react"
import { Section } from "@react-email/section"
import { Text } from "@react-email/text"
import { EMAIL_COLORS } from "./tokens"
import { formatPriority, formatStatus } from "./utils"
export type TicketCardData = {
reference: number
subject: string
companyName?: string | null
status?: string | null
priority?: string | null
requesterName?: string | null
assigneeName?: string | null
}
function badge(label: string, bg: string, color: string) {
return (
{label}
)
}
function statusBadge(status: string) {
const normalized = status.trim().toUpperCase()
const map: Record = {
PENDING: { bg: EMAIL_COLORS.statusPendingBg, color: EMAIL_COLORS.statusPending, label: "Pendente" },
AWAITING_ATTENDANCE: { bg: EMAIL_COLORS.statusProgressBg, color: EMAIL_COLORS.statusProgress, label: "Em andamento" },
PAUSED: { bg: EMAIL_COLORS.statusPausedBg, color: EMAIL_COLORS.statusPaused, label: "Pausado" },
RESOLVED: { bg: EMAIL_COLORS.statusResolvedBg, color: EMAIL_COLORS.statusResolved, label: "Resolvido" },
}
const entry = map[normalized] ?? {
bg: EMAIL_COLORS.statusPendingBg,
color: EMAIL_COLORS.statusPending,
label: formatStatus(status),
}
return badge(entry.label, entry.bg, entry.color)
}
function priorityBadge(priority: string) {
const normalized = priority.trim().toUpperCase()
const map: Record = {
LOW: { bg: EMAIL_COLORS.priorityLowBg, color: EMAIL_COLORS.priorityLow, label: "Baixa" },
MEDIUM: { bg: EMAIL_COLORS.priorityMediumBg, color: EMAIL_COLORS.priorityMedium, label: "Média" },
HIGH: { bg: EMAIL_COLORS.priorityHighBg, color: EMAIL_COLORS.priorityHigh, label: "Alta" },
URGENT: { bg: EMAIL_COLORS.priorityUrgentBg, color: EMAIL_COLORS.priorityUrgent, label: "Urgente" },
}
const entry = map[normalized] ?? {
bg: EMAIL_COLORS.priorityMediumBg,
color: EMAIL_COLORS.priorityMedium,
label: formatPriority(priority),
}
return badge(entry.label, entry.bg, entry.color)
}
function Row({ label, value }: { label: string; value: React.ReactNode }) {
return (
|
{label}
|
{value} |
)
}
export function TicketCard({ ticket }: { ticket: TicketCardData }) {
return (
#{ticket.reference}} />
{ticket.companyName ?
: null}
{ticket.status ?
: null}
{ticket.priority ?
: null}
{ticket.requesterName ?
: null}
{ticket.assigneeName ?
: null}
)
}