"use client" import { useMemo, useState } from "react" import Link from "next/link" import { useParams, usePathname } from "next/navigation" import { Icon } from "@iconify/react" import { Clock, Star, Trash2 } from "lucide-react" import { cn } from "@/lib/utils" import { DRIVE_SIDEBAR_CARET_SLOT_CLASS, DRIVE_SIDEBAR_ROW_BODY_CLASS, DRIVE_SIDEBAR_ROW_CLASS, } from "@/lib/drive/drive-chrome-classes" import { mailNavRowClass } from "@/lib/mail-chrome-classes" import { MAIL_SETTINGS_BASE_PATH } from "@/lib/mail-settings/settings-nav" import { DriveQuotaBar } from "@/components/drive/quota-bar" import { DriveNewMenu } from "@/components/drive/new-menu" import { DriveSidebarFolderTree } from "@/components/drive/sidebar-folder-tree" import { DriveSidebarOrgFolders } from "@/components/drive/drive-sidebar-org-folders" import { DriveSidebarMounts, DriveConnectMountAction } from "@/components/drive/drive-sidebar-mounts" import { AccountAvatar } from "@/components/suite/account-avatar" import { AccountSwitcherSheet } from "@/components/suite/account-switcher-sheet" import { Button } from "@/components/ui/button" import { useIsXs } from "@/hooks/use-xs" import { useDriveRouteRoot } from "@/lib/drive/drive-route-context" import { driveRouteBase, folderPathFromSegments, parseDriveSegments } from "@/lib/drive/drive-url" import { useChromeIdentity } from "@/lib/hooks/use-chrome-identity" import { useDriveUIStore } from "@/lib/stores/drive-ui-store" import { SUITE_APP_LOGO_LOCKUP_CLASS, SUITE_APP_LOGO_MARK_CLASS, SUITE_APP_LOGO_TEXT_CLASS, } from "@/lib/suite/suite-chrome-classes" export function DriveSidebar({ overlay = false, open = true, }: { overlay?: boolean open?: boolean }) { const pathname = usePathname() const params = useParams() const routeRoot = useDriveRouteRoot() const driveBase = driveRouteBase(routeRoot) const otherNav = [ { href: `${driveBase}/recent`, label: "Récents", icon: Clock }, { href: `${driveBase}/starred`, label: "Favoris", icon: Star }, { href: `${driveBase}/trash`, label: "Corbeille", icon: Trash2 }, ] const isXs = useIsXs() const identity = useChromeIdentity() const [accountMenuOpen, setAccountMenuOpen] = useState(false) const setSidebarCollapsed = useDriveUIStore((s) => s.setSidebarCollapsed) const route = useMemo( () => parseDriveSegments(params.segments as string[] | undefined), [params.segments] ) const parentPath = folderPathFromSegments(route.pathSegments) const filesSegments = route.view === "files" ? route.pathSegments : [] const sharedSegments = route.view === "shared" ? route.pathSegments : [] const orgSegments = route.view === "org" ? route.pathSegments : [] const mountSegments = route.view === "mount" ? route.pathSegments : [] const closeSidebar = () => setSidebarCollapsed(true) const displayName = identity?.name ?? "Utilisateur" return ( ) }