import * as React from "react" import { Section, Text } from "@react-email/components" 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 } export type TicketCardProps = { ticketNumber: string ticketTitle: string status?: string | null priority?: string | null category?: string | null subcategory?: string | null companyName?: 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} ) } /** @deprecated Use TicketCard with props instead */ export function TicketCardLegacy({ ticket }: { ticket: TicketCardData }) { return (
#{ticket.reference}} /> {ticket.companyName ? : null} {ticket.status ? : null} {ticket.priority ? : null} {ticket.requesterName ? : null} {ticket.assigneeName ? : null}
) } export function TicketCard(props: TicketCardProps) { const { ticketNumber, ticketTitle, status, priority, category, subcategory, companyName, requesterName, assigneeName } = props const categoryLabel = category && subcategory ? `${category} / ${subcategory}` : category ?? subcategory ?? null return (
Chamado #{ticketNumber} {ticketTitle}
{status ? ( ) : null} {priority ? ( ) : null} {categoryLabel ? ( ) : null} {companyName ? ( ) : null} {requesterName ? ( ) : null} {assigneeName ? ( ) : null}
Status {statusBadge(status)}
Prioridade {priorityBadge(priority)}
Categoria {categoryLabel}
Empresa {companyName}
Solicitante {requesterName}
Responsavel {assigneeName}
) }