diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 69c9630..1133d81 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -6,16 +6,38 @@ import { FolderOpen, BarChart3, LogOut, + ChevronDown, + Settings, } from "lucide-react"; import { useAuth } from "@/contexts/AuthContext"; +import { useState, useRef, useEffect } from "react"; export function Navbar() { const { user, logout } = useAuth(); + const [managementOpen, setManagementOpen] = useState(false); + const dropdownRef = useRef(null); - const navItems = [ + // Close dropdown when clicking outside + useEffect(() => { + function handleClickOutside(event: MouseEvent) { + if ( + dropdownRef.current && + !dropdownRef.current.contains(event.target as Node) + ) { + setManagementOpen(false); + } + } + document.addEventListener("mousedown", handleClickOutside); + return () => document.removeEventListener("mousedown", handleClickOutside); + }, []); + + const mainNavItems = [ { to: "/dashboard", label: "Dashboard", icon: Clock }, { to: "/time-entries", label: "Time Entries", icon: List }, { to: "/statistics", label: "Statistics", icon: BarChart3 }, + ]; + + const managementItems = [ { to: "/clients", label: "Clients", icon: Briefcase }, { to: "/projects", label: "Projects", icon: FolderOpen }, ]; @@ -32,7 +54,8 @@ export function Navbar() {
- {navItems.map((item) => ( + {/* Main Navigation Items */} + {mainNavItems.map((item) => ( ))} + + {/* Management Dropdown */} +
+ + + {managementOpen && ( +
+ {managementItems.map((item) => ( + setManagementOpen(false)} + className={({ isActive }) => + `flex items-center px-4 py-2 text-sm transition-colors ${ + isActive + ? "bg-primary-50 text-primary-600" + : "text-gray-700 hover:bg-gray-50" + }` + } + > + + {item.label} + + ))} +
+ )} +
@@ -64,15 +127,17 @@ export function Navbar() {
+ {/* Mobile navigation */}
-
- {navItems.map((item) => ( +
+ {/* Mobile: Show all nav items directly (no dropdown) */} + {[...mainNavItems, ...managementItems].map((item) => ( - `flex flex-col items-center p-2 text-xs font-medium rounded-md ${ + `flex-1 min-w-[80px] flex flex-col items-center p-2 text-xs font-medium ${ isActive ? "text-primary-600" : "text-gray-600" }` } diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index b2a9175..864d322 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -4,7 +4,7 @@ import { useTimeEntries } from "@/hooks/useTimeEntries"; import { formatDate, formatDurationFromDates, - formatDuration, + formatDurationHoursMinutes, } from "@/utils/dateUtils"; import { startOfDay, endOfDay } from "date-fns"; @@ -40,7 +40,7 @@ export function DashboardPage() {