@@ -18,17 +18,19 @@ import { IsLoggedIn } from '@/lib/firebase/firebase'
1818import { logoutAction } from '@/lib/actions/logout'
1919import { ModeToggle } from '@/components/button-toggle-theme'
2020import { redirect , RedirectType } from 'next/navigation'
21+ import type { Route } from 'next'
2122import { addDays , format , subMonths } from 'date-fns'
23+ type MenuItem = {
24+ title : string
25+ icon : typeof Library
26+ href : Route
27+ }
2228
23- const now = new Date ( )
24- const to = format ( addDays ( now , 1 ) , 'dd-MM-yyyy' )
25- const from = format ( subMonths ( now , 1 ) , 'dd-MM-yyyy' )
26-
27- const menuItems = [
29+ const baseMenuItems : MenuItem [ ] = [
2830 {
2931 title : 'Dashboard' ,
3032 icon : ChartSpline ,
31- href : ` /admin/dashboard?from= ${ from } &to= ${ to } ` ,
33+ href : ' /admin/dashboard' ,
3234 } ,
3335 { title : 'Libraries' , icon : Library , href : '/admin/libraries' } ,
3436 { title : 'Notifications' , icon : BellIcon , href : '/notifications' } ,
@@ -49,7 +51,9 @@ const menuItems = [
4951 { title : 'Collections' , icon : BookCopy , href : '/admin/collections' } ,
5052 { title : 'Reviews' , icon : MessageSquare , href : '/admin/reviews' } ,
5153 { title : 'Jobs' , icon : Workflow , href : '/admin/jobs' } ,
52- ] as const
54+ ]
55+
56+ export const dynamic = 'force-dynamic'
5357
5458export default async function LibraryDashboard ( ) {
5559 const claim = await IsLoggedIn ( )
@@ -68,6 +72,18 @@ export default async function LibraryDashboard() {
6872 redirect ( `/` , RedirectType . replace )
6973 }
7074
75+ const now = new Date ( )
76+ const to = format ( addDays ( now , 1 ) , 'dd-MM-yyyy' )
77+ const from = format ( subMonths ( now , 1 ) , 'dd-MM-yyyy' )
78+ const menuItems = baseMenuItems . map ( ( item ) =>
79+ item . title === 'Dashboard'
80+ ? {
81+ ...item ,
82+ href : `/admin/dashboard?from=${ from } &to=${ to } ` as Route ,
83+ }
84+ : item
85+ )
86+
7187 return (
7288 < main className = "min-h-[calc(100vh-4rem)] p-8" >
7389 < div className = "max-w-2xl mx-auto space-y-4" >
0 commit comments