"use client" import { useMemo } from "react" import { toast } from "sonner" import { BreadcrumbNav } from "@/components/drive/breadcrumb-nav" import { DriveBulkToolbar } from "@/components/drive/drive-bulk-toolbar" import { DriveFilterBar } from "@/components/drive/drive-filter-bar" import { DriveSortMenu } from "@/components/drive/drive-sort-menu" import { DriveViewModeToggle } from "@/components/drive/drive-view-mode-toggle" import { DriveSearchBreadcrumb } from "@/components/drive/drive-search-breadcrumb" import type { DriveFileInfo } from "@/lib/api/types" import type { DriveSearchState } from "@/lib/drive/drive-search" import type { DriveView } from "@/lib/drive/drive-url" import { DRIVE_CARD_PAD_X, DRIVE_FILTER_CONTENT_GAP, DRIVE_FILTER_LIST_CONTENT_GAP, } from "@/lib/drive/drive-chrome-classes" import { useDriveMutations } from "@/lib/api/hooks/use-drive-queries" import { useDriveSettingsStore } from "@/lib/stores/drive-settings-store" import { useDriveUIStore } from "@/lib/stores/drive-ui-store" import { cn } from "@/lib/utils" const VIEW_TITLES: Partial> = { recent: "Récents", starred: "Favoris", trash: "Corbeille", org: "Dossier d'organisation", mount: "Volume monté", } export function DriveBrowserChrome({ view, segments, rootId, isTrash, items, searchState, }: { view: DriveView segments: string[] rootId?: string | null isTrash?: boolean items: DriveFileInfo[] searchState?: DriveSearchState | null }) { const selectedPaths = useDriveUIStore((s) => s.selectedPaths) const clearSelection = useDriveUIStore((s) => s.clearSelection) const viewMode = useDriveSettingsStore((s) => s.viewMode) const mutations = useDriveMutations() const filterContentGap = viewMode === "list" ? DRIVE_FILTER_LIST_CONTENT_GAP : DRIVE_FILTER_CONTENT_GAP const selectedTargets = useMemo( () => items.filter((f) => selectedPaths.has(f.path)), [items, selectedPaths] ) const showBulk = selectedTargets.length > 0 const showBreadcrumb = view === "files" || view === "shared" || view === "org" || view === "mount" const showSearchBreadcrumb = view === "search" && searchState const title = VIEW_TITLES[view] const allowShare = view !== "shared" const showEmptyTrash = view === "trash" && !showBulk && items.length > 0 const onEmptyTrash = async () => { if (!window.confirm("Vider la corbeille ? Cette action est irréversible.")) return try { await mutations.emptyTrash.mutateAsync() clearSelection() toast.success("Corbeille vidée") } catch { toast.error("Impossible de vider la corbeille") } } return (
{showSearchBreadcrumb ? ( ) : showBreadcrumb ? ( ) : title ? (

{title}

{showEmptyTrash ? ( ) : null}
) : null}
{showBulk ? ( ) : ( )}
) }