Enhance admin dashboard analytics and system status

Added 'Year to Date' and 'Last Year' filters to analytics, and improved summary cards to show total revenue and orders for the selected period. Refactored SystemStatusCard to include a debug view with detailed system metrics and raw JSON response. Updated nav-item active state detection for more precision and improved navigation handling. Removed redundant recent activity card from admin status page.
This commit is contained in:
g
2025-11-28 19:22:14 +00:00
parent 4b0bd2cf8c
commit 3f8826cbc4
4 changed files with 133 additions and 85 deletions

View File

@@ -16,7 +16,8 @@ interface NavItemProps {
export const NavItem: React.FC<NavItemProps> = ({ href, icon: Icon, children, onClick }) => {
const pathname = usePathname()
const isActive = pathname === href || (href !== '/dashboard' && pathname?.startsWith(href))
// More precise active state detection - exact match or starts with href followed by /
const isActive = pathname === href || (href !== '/dashboard' && pathname?.startsWith(href + '/'))
const isNavigatingRef = useRef(false)
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
@@ -26,26 +27,18 @@ export const NavItem: React.FC<NavItemProps> = ({ href, icon: Icon, children, on
return
}
// If already on this page, just close mobile menu if needed
if (isActive) {
e.preventDefault()
if (onClick) onClick()
return
}
// Mark as navigating to prevent double-clicks
isNavigatingRef.current = true
// Call onClick handler (for mobile menu closing) - don't block navigation
// Always allow navigation - close mobile menu if needed
if (onClick) {
// Use setTimeout to ensure navigation happens first
setTimeout(() => onClick(), 0)
onClick()
}
// Reset flag after navigation completes
setTimeout(() => {
isNavigatingRef.current = false
}, 300)
}, 500)
}
return (