diff --git a/src/components/chat/chat-widget.tsx b/src/components/chat/chat-widget.tsx index ace0ddd..5083ab5 100644 --- a/src/components/chat/chat-widget.tsx +++ b/src/components/chat/chat-widget.tsx @@ -53,6 +53,40 @@ function formatTime(timestamp: number) { }) } +function formatDateSeparator(timestamp: number) { + const date = new Date(timestamp) + const today = new Date() + const yesterday = new Date(today) + yesterday.setDate(yesterday.getDate() - 1) + + const isToday = date.toDateString() === today.toDateString() + const isYesterday = date.toDateString() === yesterday.toDateString() + + if (isToday) return "Hoje" + if (isYesterday) return "Ontem" + + return date.toLocaleDateString("pt-BR", { + weekday: "long", + day: "2-digit", + month: "long", + }) +} + +function getDateKey(timestamp: number) { + return new Date(timestamp).toDateString() +} + +// Componente separador de data (estilo WhatsApp) +function DateSeparator({ timestamp }: { timestamp: number }) { + return ( +