import { type FC } from "react"; import { InfoCircle } from "iconsax-react"; import { clx } from "@/helpers/utils"; import { t } from "@/locale"; import type { TicketDetailType } from "./types/TicketTypes"; import { formatDate, getStatusClass, getStatusLabel } from "./detailUtils"; export type TicketInfoSidebarProps = { ticket: TicketDetailType; }; type ExtendedTicketFields = { numericId?: string; assignedTo?: { firstName?: string; lastName?: string }; category?: { title?: string }; priority?: string; }; const TicketInfoSidebar: FC = ({ ticket }) => { const status = ticket.status?.toUpperCase() ?? ""; const statusLabel = getStatusLabel(ticket.status); const extendedTicket = ticket as TicketDetailType & ExtendedTicketFields; const infoRows: { label: string; value: string }[] = [ { label: t("ticket.ticket_number"), value: extendedTicket.numericId ?? ticket.id }, { label: t("ticket.date"), value: formatDate(ticket.createdAt) }, ]; if (extendedTicket.assignedTo) { const name = [extendedTicket.assignedTo.firstName, extendedTicket.assignedTo.lastName] .filter(Boolean) .join(" "); if (name) infoRows.push({ label: t("ticket.asignto"), value: name }); } if (extendedTicket.category?.title) { infoRows.push({ label: t("ticket.category"), value: extendedTicket.category.title }); } if (extendedTicket.priority) { const priorityLabel = extendedTicket.priority === "low" ? t("ticket.low") : extendedTicket.priority === "medium" ? t("ticket.medium") : t("ticket.high"); infoRows.push({ label: t("ticket.priority"), value: priorityLabel }); } return (
{t("ticket.info_ticket")} {statusLabel}
{infoRows.map(({ label, value }) => (
{label}
{value}
))}
{t("ticket.update_sms")}
); }; export default TicketInfoSidebar;