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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user