diff --git a/components/app-sidebar.tsx b/components/app-sidebar.tsx index eede001..a663213 100644 --- a/components/app-sidebar.tsx +++ b/components/app-sidebar.tsx @@ -1,7 +1,7 @@ 'use client' import Link from 'next/link' -import { usePathname, useRouter } from 'next/navigation' +import { usePathname } from 'next/navigation' import { useState } from 'react' import { cn } from '@/lib/utils' import { signOut } from '@/lib/auth-actions' @@ -11,16 +11,16 @@ import { MessageSquare, Users, CreditCard, BookUser, Download, LogOut, } from 'lucide-react' -function NavLink({ - href, label, icon: Icon, badge, active, onClick, -}: { +interface NavLinkProps { href: string label: string icon: React.ElementType badge?: number active: boolean onClick?: () => void -}) { +} + +function NavLink({ href, label, icon: Icon, badge, active, onClick }: NavLinkProps) { return ( n[0]).join('').toUpperCase().slice(0, 2) + const initials = (member.display_name || 'U').split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2) const isAdmin = member.role === 'admin' || member.role === 'board' const [drawerOpen, setDrawerOpen] = useState(false) - function isActive(href: string) { - return pathname === href || pathname.startsWith(href + '/') - } + const isActive = (href: string) => pathname === href || pathname.startsWith(href + '/') - async function handleSignOut() { + const handleSignOut = async () => { await signOut() } - const SidebarContent = ({ onNav }: { onNav?: () => void }) => ( + const closeDrawer = () => setDrawerOpen(false) + + const renderNav = (onNav?: () => void) => ( <> {/* Logo */}
@@ -94,26 +84,26 @@ export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge

Workspace

- - - - - + + + + +

People

- + - + {isAdmin && ( <>

Admin

- - + + )} @@ -139,13 +129,13 @@ export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge return ( <> - {/* ── Desktop sidebar ─────────────────────────────────── */} + {/* Desktop sidebar */} - {/* ── Mobile: top bar ──────────────────────────────────── */} -
+ {/* Mobile: top bar */} +
hs @@ -161,21 +151,19 @@ export function AppSidebar({ member, taskBadge = 0, commsBadge = 0, paymentBadge
- {/* ── Mobile: full drawer ──────────────────────────────── */} + {/* Mobile: drawer overlay */} {drawerOpen && (
- {/* Backdrop */} -
setDrawerOpen(false)} /> - {/* Drawer */} +
-
+
Menu -
-
- setDrawerOpen(false)} /> +
+ {renderNav(closeDrawer)}