@@ -16,11 +16,11 @@ import {
1616 Bookmark ,
1717 Home ,
1818 KeySquareIcon ,
19- Settings ,
2019 Settings2 ,
2120} from "lucide-react" ;
2221import Link from "next/link" ;
2322import { usePathname } from "next/navigation" ;
23+ import { useUnreadNotificationCount } from "@/components/notifications/use-unread-notification-count" ;
2424
2525const DashboardSidebar = ( ) => {
2626 const { _t } = useTranslation ( ) ;
@@ -36,11 +36,6 @@ const DashboardSidebar = () => {
3636 // url: "/series",
3737 // icon: Home,
3838 // },
39- // {
40- // title: _t("Notifications"),
41- // url: "/notifications",
42- // icon: BellIcon,
43- // },
4439 {
4540 title : _t ( "Bookmarks" ) ,
4641 url : "/bookmarks" ,
@@ -64,7 +59,7 @@ const DashboardSidebar = () => {
6459 < SidebarGroupLabel > { _t ( "Dashboard" ) } </ SidebarGroupLabel >
6560 < SidebarGroupContent >
6661 < SidebarMenu >
67- { items . map ( ( item , key ) => (
62+ { items . slice ( 0 , 1 ) . map ( ( item , key ) => (
6863 < SidebarMenuItem key = { key } >
6964 < SidebarMenuButton
7065 asChild
@@ -80,6 +75,26 @@ const DashboardSidebar = () => {
8075 </ SidebarMenuButton >
8176 </ SidebarMenuItem >
8277 ) ) }
78+ < DashboardNotificationsMenuItem
79+ pathName = { pathName }
80+ label = { _t ( "Notifications" ) }
81+ />
82+ { items . slice ( 1 ) . map ( ( item , key ) => (
83+ < SidebarMenuItem key = { `rest-${ key } ` } >
84+ < SidebarMenuButton
85+ asChild
86+ isActive = { pathName === `/dashboard${ item . url } ` }
87+ >
88+ < Link
89+ className = "text-muted-foreground"
90+ href = { `/dashboard${ item . url } ` }
91+ >
92+ < item . icon />
93+ < span > { item . title } </ span >
94+ </ Link >
95+ </ SidebarMenuButton >
96+ </ SidebarMenuItem >
97+ ) ) }
8398 </ SidebarMenu >
8499 </ SidebarGroupContent >
85100 </ SidebarGroup >
@@ -88,4 +103,35 @@ const DashboardSidebar = () => {
88103 ) ;
89104} ;
90105
106+ function DashboardNotificationsMenuItem ( {
107+ pathName,
108+ label,
109+ } : {
110+ pathName : string ;
111+ label : string ;
112+ } ) {
113+ const { data : unread = 0 } = useUnreadNotificationCount ( ) ;
114+ return (
115+ < SidebarMenuItem >
116+ < SidebarMenuButton
117+ asChild
118+ isActive = { pathName === "/dashboard/notifications" }
119+ >
120+ < Link
121+ className = "text-muted-foreground flex w-full min-w-0 items-center gap-2"
122+ href = "/dashboard/notifications"
123+ >
124+ < BellIcon className = "shrink-0" />
125+ < span className = "min-w-0 flex-1 truncate" > { label } </ span >
126+ { unread > 0 ? (
127+ < span className = "flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-primary px-1.5 text-[11px] font-semibold text-primary-foreground tabular-nums" >
128+ { unread > 99 ? "99+" : unread }
129+ </ span >
130+ ) : null }
131+ </ Link >
132+ </ SidebarMenuButton >
133+ </ SidebarMenuItem >
134+ ) ;
135+ }
136+
91137export default DashboardSidebar ;
0 commit comments