From 80a53d5d159fd5e8b6c0af73540a5e00b048ac60 Mon Sep 17 00:00:00 2001 From: RKWojs Date: Mon, 6 Oct 2025 16:01:29 +0200 Subject: [PATCH] feat: Add notifications dropdown to navigation and update translations for notifications --- src/components/ui/Navigation.js | 77 +++++++++++++++++++++++++++++++-- src/lib/i18n.js | 7 +++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/src/components/ui/Navigation.js b/src/components/ui/Navigation.js index 7e26145..a31eb1e 100644 --- a/src/components/ui/Navigation.js +++ b/src/components/ui/Navigation.js @@ -4,13 +4,29 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; import { useSession, signOut } from "next-auth/react"; import { useTranslation } from "@/lib/i18n"; -import { useState } from "react"; +import { useState, useEffect, useRef } from "react"; const Navigation = () => { const pathname = usePathname(); const { data: session, status } = useSession(); const { t } = useTranslation(); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); + const [isNotificationsOpen, setIsNotificationsOpen] = useState(false); + const notificationsRef = useRef(null); + + // Close notifications dropdown when clicking outside + useEffect(() => { + const handleClickOutside = (event) => { + if (notificationsRef.current && !notificationsRef.current.contains(event.target)) { + setIsNotificationsOpen(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, []); const isActive = (path) => { if (path === "/") return pathname === "/"; @@ -74,12 +90,43 @@ const Navigation = () => { ) : null} - {/* Right side - User/Auth section */} + {/* Right side - Notifications and User/Auth section */}
{status === "loading" ? (
{t('navigation.loading')}
) : session ? ( <> + {/* Notifications */} +
+ + + {/* Notifications Dropdown */} + {isNotificationsOpen && ( +
+
+

{t('notifications.title')}

+
+
+
+

{t('notifications.noNotifications')}

+

{t('notifications.placeholder')}

+
+
+
+ )} +
+ {/* User Info */}
@@ -117,7 +164,10 @@ const Navigation = () => { {/* Mobile menu button */} {session && (
+ {/* Mobile Notifications */} +