From beb64067cf16f77a8143003ecec1fdddbafc4184 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 9 Mar 2026 08:59:55 -0300 Subject: [PATCH] feat: implement notification center in frontend shell header --- frontend/src/layouts/Shell.tsx | 60 +++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/frontend/src/layouts/Shell.tsx b/frontend/src/layouts/Shell.tsx index af0738b..1ac2c1d 100644 --- a/frontend/src/layouts/Shell.tsx +++ b/frontend/src/layouts/Shell.tsx @@ -65,7 +65,10 @@ function CartDropdownContent() { export function Shell({ children }: { children: React.ReactNode }) { const { user, logout } = useAuth() const [isProfileOpen, setIsProfileOpen] = useState(false) + const [isNotificationsOpen, setIsNotificationsOpen] = useState(false) + const [notifications, setNotifications] = useState([]) const profileMenuRef = useRef(null) + const notificationsRef = useRef(null) const { totalItems: cartCount } = useCartStore(selectCartSummary) const isOwner = user?.role === 'owner' @@ -78,13 +81,27 @@ export function Shell({ children }: { children: React.ReactNode }) { if (profileMenuRef.current && !profileMenuRef.current.contains(event.target as Node)) { setIsProfileOpen(false) } + if (notificationsRef.current && !notificationsRef.current.contains(event.target as Node)) { + setIsNotificationsOpen(false) + } } document.addEventListener('mousedown', handleClickOutside) + + // Simulate loading notifications (In prod, fetch from /api/v1/notifications) + if (user) { + setNotifications([ + { id: 1, title: 'Bem-vindo!', message: 'Explore o marketplace SaveInMed.', date: new Date().toISOString(), read: false }, + { id: 2, title: 'Perfil Completo', message: 'Seu cadastro foi verificado com sucesso.', date: new Date().toISOString(), read: true } + ]) + } + return () => { document.removeEventListener('mousedown', handleClickOutside) } - }, []) + }, [user]) + + const unreadCount = notifications.filter(n => !n.read).length return (
@@ -112,6 +129,47 @@ export function Shell({ children }: { children: React.ReactNode }) { Config. Entrega )} + + {/* Notifications */} +
+ + + {isNotificationsOpen && ( +
+
+

Notificações

+ +
+
+ {notifications.length === 0 ? ( +
Nenhuma notificação
+ ) : ( + notifications.map(n => ( +
+

{n.title}

+

{n.message}

+

{new Date(n.date).toLocaleDateString()}

+
+ )) + )} +
+
+ )} +
+