@@ -16,12 +16,15 @@ import {
1616} from 'lucide-react' ;
1717import { UserButton } from '@clerk/nextjs' ;
1818
19+ import { useState , useEffect } from 'react' ;
20+ import { getOpenTicketsCount } from '@/actions/tickets' ;
21+
1922const ADMIN_NAV = [
2023 { label : 'Dashboard' , href : '/admin' , icon : LayoutDashboard } ,
2124 { label : 'Leela Stories' , href : '/admin/leela' , icon : Footprints } ,
2225 { label : 'Bodhakatha' , href : '/admin/bodhakatha' , icon : Lightbulb } ,
2326 { label : 'Glossary' , href : '/admin/glossary' , icon : Book } ,
24- { label : 'Seeker Inquiries' , href : '/admin/tickets' , icon : Ticket } ,
27+ { label : 'Seeker Inquiries' , href : '/admin/tickets' , icon : Ticket , isTickets : true } ,
2528] ;
2629
2730export default function AdminSidebar ( {
@@ -32,6 +35,18 @@ export default function AdminSidebar({
3235 onClose ?: ( ) => void ;
3336} ) {
3437 const pathname = usePathname ( ) ;
38+ const [ openCount , setOpenCount ] = useState ( 0 ) ;
39+
40+ useEffect ( ( ) => {
41+ getOpenTicketsCount ( ) . then ( setOpenCount ) ;
42+
43+ // Refresh every 2 mins
44+ const interval = setInterval ( ( ) => {
45+ getOpenTicketsCount ( ) . then ( setOpenCount ) ;
46+ } , 120000 ) ;
47+
48+ return ( ) => clearInterval ( interval ) ;
49+ } , [ ] ) ;
3550
3651 return (
3752 < >
@@ -92,7 +107,14 @@ export default function AdminSidebar({
92107 < Icon className = { `w-5 h-5 ${ isActive ? 'text-white' : 'text-gray-400 group-hover:text-ochre' } transition-colors` } />
93108 < span className = "font-semibold text-sm" > { item . label } </ span >
94109 </ div >
95- { isActive && < ChevronRight className = "w-4 h-4 opacity-50" /> }
110+ < div className = "flex items-center gap-2" >
111+ { item . isTickets && openCount > 0 && (
112+ < span className = { `flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-[10px] font-black shadow-lg animate-in zoom-in duration-300 ${ isActive ? 'bg-white text-ochre shadow-white/20' : 'bg-red-600 text-white shadow-red-500/30' } ` } >
113+ { openCount }
114+ </ span >
115+ ) }
116+ { isActive && < ChevronRight className = "w-4 h-4 opacity-50" /> }
117+ </ div >
96118 </ Link >
97119 ) ;
98120 } ) }
0 commit comments