Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add sort index for dataroom

Marc Seitz948ca9dd7aa9
diff --git a/components/datarooms/dataroom-document-card.tsx b/components/datarooms/dataroom-document-card.tsx
index 96b703bd..02d13633 100644
--- a/components/datarooms/dataroom-document-card.tsx
+++ b/components/datarooms/dataroom-document-card.tsx
@@ -10,10 +10,7 @@ import { useTheme } from "next-themes";
import { toast } from "sonner";
import { mutate } from "swr";
-import { MoveToFolderModal } from "@/components/documents/move-folder-modal";
import BarChart from "@/components/shared/icons/bar-chart";
-import Check from "@/components/shared/icons/check";
-import Copy from "@/components/shared/icons/copy";
import NotionIcon from "@/components/shared/icons/notion";
import { Button } from "@/components/ui/button";
import {
@@ -27,8 +24,7 @@ import {
import { type DataroomFolderDocument } from "@/lib/swr/use-dataroom";
import { type DocumentWithLinksAndLinkCountAndViewCount } from "@/lib/types";
-import { nFormatter, timeAgo } from "@/lib/utils";
-import { useCopyToClipboard } from "@/lib/utils/use-copy-to-clipboard";
+import { cn, nFormatter, timeAgo } from "@/lib/utils";
import { MoveToDataroomFolderModal } from "./move-dataroom-folder-modal";
@@ -36,11 +32,13 @@ type DocumentsCardProps = {
document: DataroomFolderDocument;
teamInfo: TeamContextType | null;
dataroomId: string;
+ isDragging?: boolean;
};
export default function DataroomDocumentCard({
document: dataroomDocument,
teamInfo,
dataroomId,
+ isDragging,
}: DocumentsCardProps) {
const { theme, systemTheme } = useTheme();
const isLight =
@@ -147,9 +145,24 @@ export default function DataroomDocumentCard({
}
};
+ const handleCardClick = (e: React.MouseEvent) => {
+ if (isDragging) {
+ e.preventDefault();
+ e.stopPropagation();
+ return;
+ }
+ router.push(`/documents/${dataroomDocument.document.id}`);
+ };
+
return (
<>
- <li className="group/row relative flex items-center justify-between rounded-lg border-0 p-3 ring-1 ring-gray-200 transition-all hover:bg-secondary hover:ring-gray-300 dark:bg-secondary dark:ring-gray-700 hover:dark:ring-gray-500 sm:p-4">
+ <div
+ onClick={handleCardClick}
+ className={cn(
+ "group/row relative flex items-center justify-between rounded-lg border-0 bg-white p-3 ring-1 ring-gray-200 transition-all hover:bg-secondary hover:ring-gray-300 dark:bg-secondary dark:ring-gray-700 hover:dark:ring-gray-500 sm:p-4",
+ isDragging ? "cursor-grabbing" : "cursor-pointer",
+ )}
+ >
<div className="flex min-w-0 shrink items-center space-x-2 sm:space-x-4">
<div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
{dataroomDocument.document.type === "notion" ? (
@@ -167,13 +180,7 @@ export default function DataroomDocumentCard({
<div className="flex-col">
<div className="flex items-center">
<h2 className="min-w-0 max-w-[150px] truncate text-sm font-semibold leading-6 text-foreground sm:max-w-md">
- <Link
- href={`/documents/${dataroomDocument.document.id}`}
- className="w-full truncate"
- >
- <span>{dataroomDocument.document.name}</span>
- <span className="absolute inset-0" />
- </Link>
+ {dataroomDocument.document.name}
</h2>
</div>
<div className="mt-1 flex items-center space-x-1 text-xs leading-5 text-muted-foreground">
@@ -239,7 +246,7 @@ export default function DataroomDocumentCard({
</DropdownMenuContent>
</DropdownMenu>
</div>
- </li>
+ </div>
{moveFolderOpen ? (
<MoveToDataroomFolderModal
open={moveFolderOpen}
diff --git a/components/datarooms/sortable/sortable-item.tsx b/components/datarooms/sortable/sortable-item.tsx
new file mode 100644
index 00000000..434450f5
--- /dev/null
+++ b/components/datarooms/sortable/sortable-item.tsx
@@ -0,0 +1,48 @@
+import React from "react";
+
+import { useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+
+export type ItemCategory = "folder" | "document";
+
+interface SortableItemProps {
+ id: string;
+ category: ItemCategory;
+ children: React.ReactElement;
+}
+
+export const SortableItem: React.FC<SortableItemProps> = ({
+ id,
+ category,
+ children,
+}) => {
+ const { attributes, listeners, setNodeRef, transform, isDragging } =
+ useSortable({
+ id: id,
+ data: {
+ category: category,
+ id: id.replace(category, ""),
+ },
+ });
+
+ const style = {
+ transform: CSS.Transform.toString(transform),
+ opacity: isDragging ? 0.5 : 1,
+ };
+
+ const childWithProps = React.cloneElement(children, {
+ isDragging,
+ });
+
+ return (
+ <li
+ ref={setNodeRef}
+ style={style}
+ {...attributes}
+ {...listeners}
+ className="cursor-move *:pointer-events-none"
+ >
+ {childWithProps}
+ </li>
+ );
+};
diff --git a/components/datarooms/sortable/sortable-list.tsx b/components/datarooms/sortable/sortable-list.tsx
new file mode 100644
index 00000000..f0b68bbb
--- /dev/null
+++ b/components/datarooms/sortable/sortable-list.tsx
@@ -0,0 +1,284 @@
+import { useEffect, useState } from "react";
+import React from "react";
+
+import { TeamContextType } from "@/context/team-context";
+import {
+ DndContext,
+ DragEndEvent,
+ DragOverlay,
+ DragStartEvent,
+ KeyboardSensor,
+ PointerSensor,
+ closestCenter,
+ useSensor,
+ useSensors,
+} from "@dnd-kit/core";
+import {
+ SortableContext,
+ arrayMove,
+ sortableKeyboardCoordinates,
+ verticalListSortingStrategy,
+} from "@dnd-kit/sortable";
+
+import DataroomDocumentCard from "@/components/datarooms/dataroom-document-card";
+import FolderCard from "@/components/documents/folder-card";
+import { Skeleton } from "@/components/ui/skeleton";
+
+import {
+ DataroomFolderDocument,
+ DataroomFolderWithCount,
+} from "@/lib/swr/use-dataroom";
+
+import { ItemCategory, SortableItem } from "./sortable-item";
+
+type FolderOrDocument = DataroomFolderWithCount | DataroomFolderDocument;
+
+const isFolder = (item: FolderOrDocument): item is DataroomFolderWithCount =>
+ "_count" in item && "childFolders" in item._count;
+
+export function DataroomSortableList({
+ folders,
+ documents,
+ teamInfo,
+ dataroomId,
+ onReorder,
+}: {
+ folders: DataroomFolderWithCount[] | undefined;
+ documents: DataroomFolderDocument[] | undefined;
+ teamInfo: TeamContextType | null;
+ dataroomId: string;
+ onReorder: (newOrder: { category: ItemCategory; id: string }[]) => void;
+}) {
+ const [activeId, setActiveId] = useState<string | null>(null);
+ const [items, setItems] = useState<FolderOrDocument[]>([
+ ...(folders || []),
+ ...(documents || []),
+ ]);
+
+ useEffect(() => {
+ setItems([...(folders || []), ...(documents || [])]);
+ }, [folders, documents]);
+
+ const sensors = useSensors(
+ useSensor(PointerSensor),
+ useSensor(KeyboardSensor, {
+ coordinateGetter: sortableKeyboardCoordinates,
+ }),
+ );
+
+ const handleDragStart = (event: DragStartEvent) => {
+ const { active } = event;
+ setActiveId(active.id as string);
+ };
+
+ const handleDragEnd = (event: DragEndEvent) => {
+ const { active, over } = event;
+
+ setActiveId(null);
+
+ if (!over) {
+ return;
+ }
+
+ const activeId = active.id as string;
+ const overId = over.id as string;
+
+ if (activeId !== overId) {
+ setItems((prevItems) => {
+ const oldIndex = prevItems.findIndex(
+ (item) =>
+ `${isFolder(item) ? "folder" : "document"}-${item.id}` === activeId,
+ );
+ const newIndex = prevItems.findIndex(
+ (item) =>
+ `${isFolder(item) ? "folder" : "document"}-${item.id}` === overId,
+ );
+
+ const newItems = arrayMove(prevItems, oldIndex, newIndex);
+ // onReorder(
+ // newItems.map((item) => ({
+ // category: isFolder(item) ? "folder" : "document",
+ // id: item.id,
+ // })),
+ // );
+ console.log("reorder", newItems);
+
+ return newItems;
+ });
+ }
+
+ setActiveId(null);
+ };
+
+ const renderItem = (item: FolderOrDocument) => {
+ const itemId = `${isFolder(item) ? "folder" : "document"}-${item.id}`;
+
+ return (
+ <SortableItem
+ key={itemId}
+ id={itemId}
+ category={isFolder(item) ? "folder" : "document"}
+ >
+ {isFolder(item) ? (
+ <FolderCard
+ folder={item}
+ teamInfo={teamInfo}
+ isDataroom={!!dataroomId}
+ dataroomId={dataroomId}
+ />
+ ) : (
+ <DataroomDocumentCard
+ document={item as DataroomFolderDocument}
+ teamInfo={teamInfo}
+ dataroomId={dataroomId}
+ />
+ )}
+ </SortableItem>
+ );
+ };
+
+ const activeItem = activeId
+ ? items.find(
+ (item) =>
+ `${isFolder(item) ? "folder" : "document"}-${item.id}` === activeId,
+ )
+ : null;
+
+ return (
+ <div className="rounded-lg border-2 border-dashed border-gray-400 p-2">
+ <DndContext
+ sensors={sensors}
+ collisionDetection={closestCenter}
+ onDragEnd={handleDragEnd}
+ onDragStart={handleDragStart}
+ >
+ <SortableContext
+ items={items.map(
+ (item) => `${isFolder(item) ? "folder" : "document"}-${item.id}`,
+ )}
+ strategy={verticalListSortingStrategy}
+ >
+ <ul role="list" className="relative space-y-4">
+ {items.map(renderItem)}
+ </ul>
+ </SortableContext>
+ <DragOverlay>
+ {activeItem ? (
+ <div
+ style={{
+ transform: "scale(0.7)",
+ opacity: 1,
+ pointerEvents: "none",
+ boxShadow: "0 0 10px rgba(0, 0, 0, 0.2)",
+ }}
+ >
+ {isFolder(activeItem) ? (
+ <FolderCard
+ folder={activeItem}
+ teamInfo={teamInfo}
+ isDataroom={!!dataroomId}
+ dataroomId={dataroomId}
+ />
+ ) : (
+ <DataroomDocumentCard
+ document={activeItem}
+ teamInfo={teamInfo}
+ dataroomId={dataroomId}
+ />
+ )}
+ </div>
+ ) : null}
+ </DragOverlay>
+ {/* <DragOverlay>
+ {activeId && activeId.startsWith("document-") && (
+ <div className="opacity-50">
+ {renderItem(
+ items.find(
+ (item) =>
+ !isFolder(item) && `document-${item.id}` === activeId,
+ )!,
+ )}
+ </div>
+ )}
+ </DragOverlay> */}
+ </DndContext>
+ {/* <div className="space-y-4"> */}
+ {/* Folders list */}
+ {/* <ul role="list" className="space-y-4">
+ {folders
+ ? folders.map((folder) => {
+ return (
+ <FolderCard
+ key={folder.id}
+ folder={folder}
+ teamInfo={teamInfo}
+ isDataroom={!!dataroomId}
+ dataroomId={dataroomId}
+ />
+ );
+ })
+ : Array.from({ length: 3 }).map((_, i) => (
+ <li
+ key={i}
+ className="relative flex w-full items-center space-x-3 rounded-lg border px-4 py-5 sm:px-6 lg:px-6"
+ >
+ <Skeleton key={i} className="h-9 w-9" />
+ <div>
+ <Skeleton key={i} className="h-4 w-32" />
+ <Skeleton key={i + 1} className="mt-2 h-3 w-12" />
+ </div>
+ <Skeleton
+ key={i + 1}
+ className="absolute right-5 top-[50%] h-5 w-20 -translate-y-[50%] transform"
+ />
+ </li>
+ ))}
+ </ul> */}
+
+ {/* Documents list */}
+ {/* <ul role="list" className="space-y-4">
+ {documents
+ ? documents.map((document) => {
+ if (dataroomId) {
+ return (
+ <DataroomDocumentCard
+ key={document.id}
+ document={document as DataroomFolderDocument}
+ teamInfo={teamInfo}
+ dataroomId={dataroomId}
+ />
+ );
+ } else {
+ return (
+ <DocumentCard
+ key={document.id}
+ document={
+ document as DocumentWithLinksAndLinkCountAndViewCount
+ }
+ teamInfo={teamInfo}
+ />
+ );
+ }
+ })
+ : Array.from({ length: 3 }).map((_, i) => (
+ <li
+ key={i}
+ className="relative flex w-full items-center space-x-3 rounded-lg border px-4 py-5 sm:px-6 lg:px-6"
+ >
+ <Skeleton key={i} className="h-9 w-9" />
+ <div>
+ <Skeleton key={i} className="h-4 w-32" />
+ <Skeleton key={i + 1} className="mt-2 h-3 w-12" />
+ </div>
+ <Skeleton
+ key={i + 1}
+ className="absolute right-5 top-[50%] h-5 w-20 -translate-y-[50%] transform"
+ />
+ </li>
+ ))}
+ </ul> */}
+
+ {/* </div> */}
+ </div>
+ );
+}
diff --git a/package-lock.json b/package-lock.json
index b6008e57..a45d50b9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,9 @@
"@aws-sdk/cloudfront-signer": "^3.621.0",
"@aws-sdk/s3-request-presigner": "^3.621.0",
"@chronark/zod-bird": "^0.3.9",
+ "@dnd-kit/core": "^6.1.0",
+ "@dnd-kit/sortable": "^8.0.0",
+ "@dnd-kit/utilities": "^3.2.2",
"@github/webauthn-json": "^2.1.1",
"@jitsu/js": "^1.9.6",
"@next-auth/prisma-adapter": "^1.0.7",
@@ -1847,6 +1850,55 @@
"zod": "^3.22.4"
}
},
+ "node_modules/@dnd-kit/accessibility": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.0.tgz",
+ "integrity": "sha512-ea7IkhKvlJUv9iSHJOnxinBcoOI3ppGnnL+VDJ75O45Nss6HtZd8IdN8touXPDtASfeI2T2LImb8VOZcL47wjQ==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/core": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.1.0.tgz",
+ "integrity": "sha512-J3cQBClB4TVxwGo3KEjssGEXNJqGVWx17aRTZ1ob0FliR5IjYgTxl5YJbKTzA6IzrtelotH19v6y7uoIRUZPSg==",
+ "dependencies": {
+ "@dnd-kit/accessibility": "^3.1.0",
+ "@dnd-kit/utilities": "^3.2.2",
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0",
+ "react-dom": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/sortable": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/sortable/-/sortable-8.0.0.tgz",
+ "integrity": "sha512-U3jk5ebVXe1Lr7c2wU7SBZjcWdQP+j7peHJfCspnA81enlu88Mgd7CC8Q+pub9ubP7eKVETzJW+IBAhsqbSu/g==",
+ "dependencies": {
+ "@dnd-kit/utilities": "^3.2.2",
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "@dnd-kit/core": "^6.1.0",
+ "react": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/utilities": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/utilities/-/utilities-3.2.2.tgz",
+ "integrity": "sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
"node_modules/@emotion/is-prop-valid": {
"version": "0.8.8",
"resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz",
diff --git a/package.json b/package.json
index 9e0f5b40..6cfc0f98 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,9 @@
"@aws-sdk/cloudfront-signer": "^3.621.0",
"@aws-sdk/s3-request-presigner": "^3.621.0",
"@chronark/zod-bird": "^0.3.9",
+ "@dnd-kit/core": "^6.1.0",
+ "@dnd-kit/sortable": "^8.0.0",
+ "@dnd-kit/utilities": "^3.2.2",
"@github/webauthn-json": "^2.1.1",
"@jitsu/js": "^1.9.6",
"@next-auth/prisma-adapter": "^1.0.7",
diff --git a/pages/datarooms/[id]/documents/[...name].tsx b/pages/datarooms/[id]/documents/[...name].tsx
index 4a5e1653..6d68d2f3 100644
--- a/pages/datarooms/[id]/documents/[...name].tsx
+++ b/pages/datarooms/[id]/documents/[...name].tsx
@@ -1,7 +1,16 @@
import { useRouter } from "next/router";
+import { useState } from "react";
+
import { useTeam } from "@/context/team-context";
-import { FileIcon, FolderIcon, FolderPlusIcon, PlusIcon } from "lucide-react";
+import {
+ ArrowUpDownIcon,
+ CheckIcon,
+ FileIcon,
+ FolderIcon,
+ FolderPlusIcon,
+ PlusIcon,
+} from "lucide-react";
import { BreadcrumbComponent } from "@/components/datarooms/dataroom-breadcrumb";
import { DataroomHeader } from "@/components/datarooms/dataroom-header";
@@ -30,6 +39,8 @@ export default function Documents() {
const teamInfo = useTeam();
+ const [reorderItems, setReorderItems] = useState<boolean>(false);
+
return (
<AppLayout>
<div className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
@@ -109,29 +120,57 @@ export default function Documents() {
</ScrollArea>
</div>
<div className="space-y-4 md:col-span-3">
- <BreadcrumbComponent />
- <section className="mb-2 flex items-center gap-x-2">
- {folders && folders.length > 0 ? (
- <p className="flex items-center gap-x-1 text-sm text-gray-400">
- <FolderIcon className="h-4 w-4" />
- <span>{folders.length} folders</span>
- </p>
- ) : null}
- {documents && documents.length > 0 ? (
- <p className="flex items-center gap-x-1 text-sm text-gray-400">
- <FileIcon className="h-4 w-4" />
- <span>{documents.length} documents</span>
- </p>
- ) : null}
- </section>
+ <div className="flex justify-between">
+ <div className="space-y-2">
+ <BreadcrumbComponent />
+ <section className="mb-2 flex items-center gap-x-2">
+ {folders && folders.length > 0 ? (
+ <p className="flex items-center gap-x-1 text-sm text-gray-400">
+ <FolderIcon className="h-4 w-4" />
+ <span>{folders.length} folders</span>
+ </p>
+ ) : null}
+ {documents && documents.length > 0 ? (
+ <p className="flex items-center gap-x-1 text-sm text-gray-400">
+ <FileIcon className="h-4 w-4" />
+ <span>{documents.length} documents</span>
+ </p>
+ ) : null}
+ </section>
+ </div>
+ <div>
+ <Button
+ size="sm"
+ variant="outline"
+ className="gap-x-1"
+ onClick={() => setReorderItems(!reorderItems)}
+ >
+ {reorderItems ? (
+ <CheckIcon className="size-4" />
+ ) : (
+ <ArrowUpDownIcon className="h-4 w-4" />
+ )}
+ {reorderItems ? "Save index" : "Edit index"}
+ </Button>
+ </div>
+ </div>
- <DocumentsList
- documents={documents}
- folders={folders}
- teamInfo={teamInfo}
- folderPathName={name}
- dataroomId={dataroom?.id}
- />
+ {reorderItems ? (
+ <DataroomSortableList
+ documents={documents}
+ folders={folders}
+ teamInfo={teamInfo}
+ dataroomId={dataroom?.id!}
+ />
+ ) : (
+ <DocumentsList
+ documents={documents}
+ folders={folders}
+ teamInfo={teamInfo}
+ folderPathName={name}
+ dataroomId={dataroom?.id}
+ />
+ )}
</div>
</div>
</div>
diff --git a/pages/datarooms/[id]/documents/index.tsx b/pages/datarooms/[id]/documents/index.tsx
index 899b3178..991f7623 100644
--- a/pages/datarooms/[id]/documents/index.tsx
+++ b/pages/datarooms/[id]/documents/index.tsx
@@ -1,9 +1,19 @@
+import { useState } from "react";
+
import { useTeam } from "@/context/team-context";
-import { FileIcon, FolderIcon, FolderPlusIcon, PlusIcon } from "lucide-react";
+import {
+ ArrowUpDownIcon,
+ CheckIcon,
+ FileIcon,
+ FolderIcon,
+ FolderPlusIcon,
+ PlusIcon,
+} from "lucide-react";
import { BreadcrumbComponent } from "@/components/datarooms/dataroom-breadcrumb";
import { DataroomHeader } from "@/components/datarooms/dataroom-header";
import { SidebarFolderTree } from "@/components/datarooms/folders";
+import { DataroomSortableList } from "@/components/datarooms/sortable/sortable-list";
import { AddDocumentModal } from "@/components/documents/add-document-modal";
import { DocumentsList } from "@/components/documents/documents-list";
import { AddFolderModal } from "@/components/folders/add-folder-modal";
@@ -24,6 +34,8 @@ export default function Documents() {
const { folders } = useDataroomFolders({ root: true });
const teamInfo = useTeam();
+ const [reorderItems, setReorderItems] = useState<boolean>(false);
+
return (
<AppLayout>
<div className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
@@ -103,28 +115,56 @@ export default function Documents() {
</ScrollArea>
</div>
<div className="space-y-4 md:col-span-3">
- <BreadcrumbComponent />
- <section className="mb-2 flex items-center gap-x-2">
- {folders && folders.length > 0 ? (
- <p className="flex items-center gap-x-1 text-sm text-gray-400">
- <FolderIcon className="h-4 w-4" />
- <span>{folders.length} folders</span>
- </p>
- ) : null}
- {documents && documents.length > 0 ? (
- <p className="flex items-center gap-x-1 text-sm text-gray-400">
- <FileIcon className="h-4 w-4" />
- <span>{documents.length} documents</span>
- </p>
- ) : null}
- </section>
+ <div className="flex justify-between">
+ <div className="space-y-2">
+ <BreadcrumbComponent />
+ <section className="mb-2 flex items-center gap-x-2">
+ {folders && folders.length > 0 ? (
+ <p className="flex items-center gap-x-1 text-sm text-gray-400">
+ <FolderIcon className="h-4 w-4" />
+ <span>{folders.length} folders</span>
+ </p>
+ ) : null}
+ {documents && documents.length > 0 ? (
+ <p className="flex items-center gap-x-1 text-sm text-gray-400">
+ <FileIcon className="h-4 w-4" />
+ <span>{documents.length} documents</span>
+ </p>
+ ) : null}
+ </section>
+ </div>
+ <div>
+ <Button
+ size="sm"
+ variant="outline"
+ className="gap-x-1"
+ onClick={() => setReorderItems(!reorderItems)}
+ >
+ {reorderItems ? (
+ <CheckIcon className="size-4" />
+ ) : (
+ <ArrowUpDownIcon className="h-4 w-4" />
+ )}
+ {reorderItems ? "Save index" : "Edit index"}
+ </Button>
+ </div>
+ </div>
- <DocumentsList
- documents={documents}
- folders={folders}
- teamInfo={teamInfo}
- dataroomId={dataroom?.id}
- />
+ {reorderItems ? (
+ <DataroomSortableList
+ documents={documents}
+ folders={folders}
+ teamInfo={teamInfo}
+ dataroomId={dataroom?.id!}
+ />
+ ) : (
+ <DocumentsList
+ documents={documents}
+ folders={folders}
+ teamInfo={teamInfo}
+ dataroomId={dataroom?.id}
+ />
+ )}
</div>
</div>
</div>