'use client' import * as React from 'react' import { cn } from '../../../utils/cn' import { ChevronRight } from 'lucide-react' import { TicketStatusTag, resolveStatusTagProps, resolveTicketStatus } from '../../ui/ticket-status-tag' import { Tag } from '../../ui/tag' import { Skeleton } from '../../ui/skeleton' import { WrenchIcon } from '../../icons-v2-generated/household/wrench-icon' export interface ChatTicketItemData { id: string title: string ticketNumber: string /** Accepts any known ticket status format (ACTIVE, active, ACTION_REQUIRED, etc.) */ status: string /** Optional badge label override. If set, the badge text reads this * (e.g. HubSpot's `pipeline_stage_label` — "New" / "Closed" / * "Waiting on contact" / "Waiting on version release") while the * variant + check icon still come from the canonical `status`. * When omitted, the canonical status's default label is used * ("Resolved" for closed, "Active" for open, etc.). */ statusLabel?: string /** Lifecycle (custom-status) kind — drives canonical-vs-color styling. */ statusKind?: string /** Lifecycle (custom-status) hex color, used when the kind isn't canonical. */ statusColor?: string category?: string timeAgo?: string /** When set, renders a "Linked work" chip with a wrench icon next to * the status tag — tells the customer at a glance that an internal * delivery task is in flight for this ticket, even before they * expand the row. The label is the linked task's status (e.g. * "Waiting on version release") so the chip carries the actual * progress signal, not just a generic marker. */ linkedTaskLabel?: string } export interface ChatTicketItemProps extends Omit, 'onClick'> { /** Optional while `isLoading` — the skeleton placeholder needs no data. */ ticket?: ChatTicketItemData onClick?: (ticketId: string) => void /** Render a non-interactive skeleton placeholder sized to a real row. */ isLoading?: boolean } const ChatTicketItem = React.forwardRef( ({ className, ticket, onClick, isLoading = false, ...props }, ref) => { if (isLoading) { return (
{/* title line */} {/* subtitle line */}
{/* status tag */} {/* chevron box */}
) } if (!ticket) return null const statusTagProps = resolveStatusTagProps({ status: ticket.status, statusKind: ticket.statusKind, statusName: ticket.statusLabel, statusColor: ticket.statusColor, }) const isResolved = ticket.statusKind === 'RESOLVED' || resolveTicketStatus(ticket.status) === 'RESOLVED' const subtitle = [ticket.ticketNumber, ticket.category, ticket.timeAgo] .filter(Boolean) .join(' \u2022 ') return ( ) }, ) ChatTicketItem.displayName = 'ChatTicketItem' export { ChatTicketItem }