import { BellIcon } from '@heroicons/react/outline' import clsx from 'clsx' import { Row } from 'web/components/layout/row' import { useEffect, useState } from 'react' import { useUser } from 'web/hooks/use-user' import { useRouter } from 'next/router' import { usePreferredGroupedNotifications } from 'web/hooks/use-notifications' export default function NotificationsIcon(props: { className?: string }) { const user = useUser() const notifications = usePreferredGroupedNotifications(user?.id, { unseenOnly: true, }) const [seen, setSeen] = useState(false) const router = useRouter() useEffect(() => { if (router.pathname.endsWith('notifications')) return setSeen(true) else setSeen(false) }, [router.pathname]) return (
{!seen && notifications && notifications.length > 0 && (
{notifications.length}
)}
) }