"use client"; import { Badge } from "@/components/ui/badge"; import { Button, buttonVariants } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { markAllUpdatesAsRead } from "@/lib/changelog/actions"; import type { ChangelogEntry } from "@/lib/changelog/data"; import { getCategoryLabel, groupEntriesByCategory, } from "@/lib/changelog/utils"; import { cn } from "@/lib/utils"; import { RiMegaphoneLine } from "@remixicon/react"; import { formatDistanceToNow } from "date-fns"; import { ptBR } from "date-fns/locale"; import { useState } from "react"; interface ChangelogNotificationProps { unreadCount: number; entries: ChangelogEntry[]; } export function ChangelogNotification({ unreadCount: initialUnreadCount, entries, }: ChangelogNotificationProps) { const [unreadCount, setUnreadCount] = useState(initialUnreadCount); const [isOpen, setIsOpen] = useState(false); const handleMarkAllAsRead = async () => { const updateIds = entries.map((e) => e.id); await markAllUpdatesAsRead(updateIds); setUnreadCount(0); }; const grouped = groupEntriesByCategory(entries); return ( Novidades

Novidades

{unreadCount > 0 && ( )}
{Object.entries(grouped).map(([category, categoryEntries]) => (

{getCategoryLabel(category)}

{categoryEntries.map((entry) => (
{entry.icon}
#{entry.id.substring(0, 7)}

{entry.title}

{formatDistanceToNow(new Date(entry.date), { addSuffix: true, locale: ptBR, })}

))}
))} {entries.length === 0 && (
Nenhuma atualização recente
)}
); }