Skip to content

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

refactor: cleanup nav props

Marc Seitz558480a5454a
diff --git a/components/NotionPage.tsx b/components/NotionPage.tsx
index 775c3282..9a3d148e 100644
--- a/components/NotionPage.tsx
+++ b/components/NotionPage.tsx
@@ -3,7 +3,6 @@ import dynamic from "next/dynamic";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import React from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
import { Slash } from "lucide-react";
import { ExtendedRecordMap } from "notion-types";
import { useQueryState } from "nuqs";
@@ -15,21 +14,19 @@ import { NotionTheme } from "@/lib/types";
import { cn } from "@/lib/utils";
import { determineTextColor } from "@/lib/utils/determine-text-color";
-// custom styles for notion
-import "@/styles/custom-notion-styles.css";
-
import {
- Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
- BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "./ui/breadcrumb";
import { Portal } from "./ui/portal";
import { ScreenProtector } from "./view/ScreenProtection";
import { TDocumentData } from "./view/dataroom/dataroom-view";
-import Nav from "./view/nav";
+import Nav, { TNavData } from "./view/nav";
+
+// custom styles for notion
+import "@/styles/custom-notion-styles.css";
const Collection = dynamic(() =>
import("react-notion-x/build/third-party/collection").then(
@@ -39,33 +36,18 @@ const Collection = dynamic(() =>
export const NotionPage = ({
recordMap,
- rootPageId,
- viewId,
- linkId,
- documentId,
- documentName,
versionNumber,
- brand,
- dataroomId,
- setDocumentData,
- isPreview,
theme,
screenshotProtectionEnabled,
+ navData,
}: {
recordMap: ExtendedRecordMap;
- rootPageId?: string;
- viewId?: string;
- linkId: string;
- documentId: string;
versionNumber: number;
- documentName?: string;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
- isPreview?: boolean;
theme?: NotionTheme | null;
screenshotProtectionEnabled: boolean;
+ navData: TNavData;
}) => {
+ const { isPreview, linkId, documentId, viewId, brand, dataroomId } = navData;
const [pageNumber, setPageNumber] = useState<number>(1); // start on first page
const [maxScrollPercentage, setMaxScrollPercentage] = useState<number>(0);
const [loading, setLoading] = useState<boolean>(false);
@@ -317,17 +299,7 @@ export const NotionPage = ({
return (
<div className="bg-white">
- <Nav
- brand={brand}
- documentName={documentName}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- type="notion"
- isPreview={isPreview}
- linkId={linkId}
- documentId={documentId}
- viewId={viewId}
- />
+ <Nav type="notion" navData={navData} />
<Portal
containerId="view-breadcrump-portal"
@@ -378,7 +350,6 @@ export const NotionPage = ({
recordMap={recordMapState}
fullPage={true}
darkMode={theme ? theme === "dark" : false}
- rootPageId={rootPageId}
disableHeader={true}
components={{
Collection,
diff --git a/components/view/PDFViewer.tsx b/components/view/PDFViewer.tsx
index 280cf3a1..d138b615 100644
--- a/components/view/PDFViewer.tsx
+++ b/components/view/PDFViewer.tsx
@@ -9,6 +9,8 @@ import Nav from "./nav";
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`;
export default function PDFViewer(props: any) {
+ const { isPreview, linkId, documentId, viewId } = props.navData;
+
const [numPages, setNumPages] = useState<number>(0);
const [pageNumber, setPageNumber] = useState<number>(1); // start on first page
const [loading, setLoading] = useState(true);
@@ -134,12 +136,13 @@ export default function PDFViewer(props: any) {
await fetch("/api/record_view", {
method: "POST",
body: JSON.stringify({
- linkId: props.linkId,
- documentId: props.documentId,
- viewId: props.viewId,
+ linkId: linkId,
+ documentId: documentId,
+ viewId: viewId,
duration: duration,
pageNumber: pageNumberRef.current,
versionNumber: props.versionNumber,
+ isPreview: isPreview,
}),
headers: {
"Content-Type": "application/json",
@@ -151,7 +154,7 @@ export default function PDFViewer(props: any) {
await fetch(`/api/teams/${teamInfo?.currentTeam?.id}/documents/update`, {
method: "POST",
body: JSON.stringify({
- documentId: props.documentId,
+ documentId: documentId,
numPages: numPages,
}),
headers: {
@@ -165,11 +168,7 @@ export default function PDFViewer(props: any) {
<Nav
pageNumber={pageNumber}
numPages={numPages}
- allowDownload={props.allowDownload}
- assistantEnabled={props.assistantEnabled}
- viewId={props.viewId}
- linkId={props.linkId}
- documentId={props.documentId}
+ navData={props.navData}
/>
<div
hidden={loading}
diff --git a/components/view/dataroom/nav-dataroom.tsx b/components/view/dataroom/nav-dataroom.tsx
index d4d02c10..eacf35c1 100644
--- a/components/view/dataroom/nav-dataroom.tsx
+++ b/components/view/dataroom/nav-dataroom.tsx
@@ -1,65 +1,53 @@
-import Image from "next/image";
import Link from "next/link";
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
import { DataroomBrand } from "@prisma/client";
-import { ArrowUpRight, Download } from "lucide-react";
+import { Download, MessagesSquareIcon } from "lucide-react";
import { toast } from "sonner";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuShortcut,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-
import { timeAgo } from "@/lib/utils";
-import PapermarkSparkle from "../../shared/icons/papermark-sparkle";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { TooltipProvider } from "@/components/ui/tooltip";
+
import { Button } from "../../ui/button";
-import { TDocumentData } from "./dataroom-view";
+import { ConversationSidebar } from "../conversations/sidebar";
export default function DataroomNav({
- pageNumber,
- numPages,
allowDownload,
- assistantEnabled,
brand,
viewId,
linkId,
- type,
- embeddedLinks,
- isDataroom,
- setDocumentData,
dataroom,
isPreview,
+ dataroomId,
+ viewerId,
+ conversationsEnabled,
}: {
- pageNumber?: number;
- numPages?: number;
allowDownload?: boolean;
- assistantEnabled?: boolean;
brand?: Partial<DataroomBrand>;
- embeddedLinks?: string[];
viewId?: string;
linkId?: string;
- type?: "pdf" | "notion";
- isDataroom?: boolean;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
dataroom?: any;
isPreview?: boolean;
+ dataroomId?: string;
+ viewerId?: string;
+ conversationsEnabled?: boolean;
}) {
const [loading, setLoading] = useState<boolean>(false);
+ const [showConversations, setShowConversations] = useState<boolean>(false);
const downloadDataroom = async () => {
if (isPreview) {
toast.error("You cannot download datarooms in preview mode.");
return;
}
- if (!allowDownload || type === "notion") return;
+ if (!allowDownload) return;
setLoading(true);
try {
toast.promise(
@@ -92,6 +80,31 @@ export default function DataroomNav({
}
};
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ // Toggle conversations with 'c' key
+ if (
+ e.key === "c" &&
+ !e.metaKey &&
+ !e.ctrlKey &&
+ !e.altKey &&
+ conversationsEnabled &&
+ !showConversations // if conversations are already open, don't toggle them
+ ) {
+ e.preventDefault();
+ setShowConversations((prev) => !prev);
+ }
+
+ if (e.key === "Escape" && showConversations) {
+ e.preventDefault();
+ setShowConversations(false);
+ }
+ };
+
+ window.addEventListener("keydown", handleKeyDown);
+ return () => window.removeEventListener("keydown", handleKeyDown);
+ }, [conversationsEnabled, showConversations]);
+
return (
<nav
className="bg-black"
@@ -114,7 +127,7 @@ export default function DataroomNav({
/>
) : (
<Link
- href="https://www.papermark.com"
+ href={`https://www.papermark.com/home?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
target="_blank"
className="text-2xl font-bold tracking-tighter text-white"
>
@@ -122,64 +135,27 @@ export default function DataroomNav({
</Link>
)}
</div>
- {isDataroom && setDocumentData ? (
- <div>
- <Button
- onClick={() => setDocumentData(null)}
- className="text-sm font-medium text-white"
- variant="link"
- >
- Dataroom Home
- </Button>
- </div>
- ) : null}
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
- {embeddedLinks && embeddedLinks.length > 0 ? (
- <DropdownMenu>
- <DropdownMenuTrigger>
- <Button className="bg-gray-900 text-sm font-medium text-white hover:bg-gray-900/80">
- Links on Page
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent className="space-y-2" align="end">
- <DropdownMenuLabel>Links on current page</DropdownMenuLabel>
- <DropdownMenuSeparator />
- {embeddedLinks.map((link, index) => (
- <Link
- href={link}
- target="_blank"
- rel="noopener noreferrer"
- key={index}
+ {conversationsEnabled && (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ onClick={() => setShowConversations(!showConversations)}
+ className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
+ size="icon"
>
- <DropdownMenuItem className="group h-10">
- <span className="w-[200px] truncate group-focus:overflow-x-auto group-focus:text-clip">
- {link}
- </span>
- <DropdownMenuShortcut className="pl-2 opacity-0 group-hover:opacity-60 group-focus:opacity-60">
- <ArrowUpRight />
- </DropdownMenuShortcut>
- </DropdownMenuItem>
- </Link>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- ) : null}
- {assistantEnabled ? (
- <Link href={`/view/${linkId}/chat`}>
- <Button
- className="m-1 bg-gray-900 text-white hover:bg-gray-900/80"
- variant={"special"}
- size={"icon"}
- style={{
- backgroundSize: "200% auto",
- }}
- title="Open AI Document Assistant"
- >
- <PapermarkSparkle className="h-5 w-5" />
- </Button>
- </Link>
- ) : null}
+ <MessagesSquareIcon className="h-5 w-5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ <p>Toggle conversations</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+
{allowDownload ? (
<Button
onClick={downloadDataroom}
@@ -191,12 +167,6 @@ export default function DataroomNav({
<Download className="h-5 w-5" />
</Button>
) : null}
- {pageNumber && numPages ? (
- <div className="flex h-10 items-center rounded-md bg-gray-900 px-4 py-2 text-sm font-medium text-white">
- <span>{pageNumber}</span>
- <span className="text-gray-400"> / {numPages}</span>
- </div>
- ) : null}
</div>
</div>
</div>
@@ -224,6 +194,18 @@ export default function DataroomNav({
</div>
</div>
) : null}
+
+ {conversationsEnabled && showConversations ? (
+ <ConversationSidebar
+ dataroomId={dataroomId}
+ viewId={viewId || ""}
+ viewerId={viewerId}
+ linkId={linkId!}
+ isEnabled={true}
+ isOpen={showConversations}
+ onOpenChange={setShowConversations}
+ />
+ ) : null}
</nav>
);
}
diff --git a/components/view/nav.tsx b/components/view/nav.tsx
index 2196f9dd..4091c4f0 100644
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@ -1,18 +1,21 @@
import Link from "next/link";
import { useRouter } from "next/router";
-import React from "react";
+import React, { useEffect, useState } from "react";
import { Brand, DataroomBrand } from "@prisma/client";
import {
ArrowUpRight,
Download,
+ MessageCircle,
Slash,
ZoomInIcon,
ZoomOutIcon,
} from "lucide-react";
import { toast } from "sonner";
+import { determineTextColor } from "@/lib/utils/determine-text-color";
+
import {
DropdownMenu,
DropdownMenuContent,
@@ -29,8 +32,6 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
-import { determineTextColor } from "@/lib/utils/determine-text-color";
-
import PapermarkSparkle from "../shared/icons/papermark-sparkle";
import {
Breadcrumb,
@@ -41,45 +42,41 @@ import {
BreadcrumbSeparator,
} from "../ui/breadcrumb";
import { Button } from "../ui/button";
-import { TDocumentData } from "./dataroom/dataroom-view";
+import { ConversationSidebar } from "./conversations/sidebar";
import ReportForm from "./report-form";
+export type TNavData = {
+ linkId: string;
+ documentId: string;
+ allowDownload?: boolean;
+ brand?: Partial<Brand> | Partial<DataroomBrand> | null;
+ isDataroom?: boolean;
+ viewId?: string;
+ viewerId?: string;
+ isMobile?: boolean;
+ isPreview?: boolean;
+
+ dataroomId?: string;
+ conversationsEnabled?: boolean;
+ assistantEnabled?: boolean;
+};
+
export default function Nav({
+ navData,
+ type,
pageNumber,
numPages,
- allowDownload,
- assistantEnabled,
- brand,
- viewId,
- linkId,
- type,
embeddedLinks,
- documentName,
- isDataroom,
- setDocumentData,
- isMobile,
- isPreview,
hasWatermark,
- documentId,
handleZoomIn,
handleZoomOut,
}: {
+ navData: TNavData;
+ type?: "pdf" | "notion" | "sheet";
pageNumber?: number;
numPages?: number;
- allowDownload?: boolean;
- assistantEnabled?: boolean;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
embeddedLinks?: string[];
- viewId?: string;
- linkId?: string;
- type?: "pdf" | "notion" | "sheet";
- documentName?: string;
- isDataroom?: boolean;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
- isMobile?: boolean;
- isPreview?: boolean;
hasWatermark?: boolean;
- documentId?: string;
handleZoomIn?: () => void;
handleZoomOut?: () => void;
}) {
@@ -87,6 +84,23 @@ export default function Nav({
const asPath = router.asPath;
const { previewToken, preview } = router.query;
+ const {
+ linkId,
+ allowDownload,
+ brand,
+ isDataroom,
+ viewId,
+ viewerId,
+ isMobile,
+ isPreview,
+ documentId,
+ dataroomId,
+ conversationsEnabled,
+ assistantEnabled,
+ } = navData;
+
+ const [showConversations, setShowConversations] = useState(false);
+
// Extract the dataroom path from the URL
// This regex captures everything before "/d/" in the path
const dataroomPathMatch = asPath.match(/^(.*?)\/d\//);
@@ -134,6 +148,32 @@ export default function Nav({
}
};
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ // Toggle conversations with 'c' key
+ if (
+ e.key === "c" &&
+ !e.metaKey &&
+ !e.ctrlKey &&
+ !e.altKey &&
+ isDataroom &&
+ conversationsEnabled &&
+ !showConversations // if conversations are already open, don't toggle them
+ ) {
+ e.preventDefault();
+ setShowConversations((prev) => !prev);
+ }
+
+ if (e.key === "Escape" && showConversations) {
+ e.preventDefault();
+ setShowConversations(false);
+ }
+ };
+
+ window.addEventListener("keydown", handleKeyDown);
+ return () => window.removeEventListener("keydown", handleKeyDown);
+ }, [isDataroom, conversationsEnabled, showConversations]);
+
return (
<nav
className="bg-black"
@@ -156,7 +196,7 @@ export default function Nav({
/>
) : (
<Link
- href={`https://www.papermark.com?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
+ href={`https://www.papermark.com/home?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
target="_blank"
className="text-2xl font-bold tracking-tighter text-white"
>
@@ -197,6 +237,25 @@ export default function Nav({
) : null}
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-2 pr-2 sm:static sm:inset-auto sm:ml-6 sm:space-x-4 sm:pr-0">
+ {/* Conversation toggle button for dataroom documents */}
+ {isDataroom && conversationsEnabled && (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ onClick={() => setShowConversations(!showConversations)}
+ className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
+ size="icon"
+ >
+ <MessageCircle className="h-5 w-5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ <p>Toggle conversations</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
{embeddedLinks && embeddedLinks.length > 0 ? (
<DropdownMenu>
<DropdownMenuTrigger>
@@ -321,6 +380,18 @@ export default function Nav({
</div>
</div>
</div>
+ {isDataroom && conversationsEnabled && showConversations ? (
+ <ConversationSidebar
+ dataroomId={dataroomId}
+ documentId={documentId}
+ viewId={viewId || ""}
+ viewerId={viewerId}
+ linkId={linkId!}
+ isEnabled={true}
+ isOpen={showConversations}
+ onOpenChange={setShowConversations}
+ />
+ ) : null}
</nav>
);
}
diff --git a/components/view/view-data.tsx b/components/view/view-data.tsx
index d605289d..831860bb 100644
--- a/components/view/view-data.tsx
+++ b/components/view/view-data.tsx
@@ -1,19 +1,27 @@
import dynamic from "next/dynamic";
-import { Brand, Document, DocumentVersion } from "@prisma/client";
+import {
+ Brand,
+ DataroomBrand,
+ Document,
+ DocumentVersion,
+} from "@prisma/client";
import { ExtendedRecordMap } from "notion-types";
-import { NotionPage } from "@/components/NotionPage";
-import PDFViewer from "@/components/view/PDFViewer";
-import { DEFAULT_DOCUMENT_VIEW_TYPE } from "@/components/view/document-view";
-
import {
LinkWithDataroomDocument,
LinkWithDocument,
NotionTheme,
WatermarkConfig,
} from "@/lib/types";
+import { useMediaQuery } from "@/lib/utils/use-media-query";
+
+import { NotionPage } from "@/components/NotionPage";
+import PDFViewer from "@/components/view/PDFViewer";
+import { DEFAULT_DOCUMENT_VIEW_TYPE } from "@/components/view/document-view";
+import { DEFAULT_DATAROOM_DOCUMENT_VIEW_TYPE } from "./dataroom/dataroom-document-view";
+import { TNavData } from "./nav";
import AdvancedExcelViewer from "./viewer/advanced-excel-viewer";
import DownloadOnlyViewer from "./viewer/download-only-viewer";
import ImageViewer from "./viewer/image-viewer";
@@ -42,7 +50,7 @@ export default function ViewData({
viewerEmail,
dataroomId,
}: {
- viewData: DEFAULT_DOCUMENT_VIEW_TYPE;
+ viewData: DEFAULT_DOCUMENT_VIEW_TYPE | DEFAULT_DATAROOM_DOCUMENT_VIEW_TYPE;
link: LinkWithDocument | LinkWithDataroomDocument;
document: TViewDocumentData;
notionData?: {
@@ -50,105 +58,81 @@ export default function ViewData({
recordMap: ExtendedRecordMap | null;
theme: NotionTheme | null;
};
- brand?: Partial<Brand> | null;
+ brand?: Partial<Brand> | Partial<DataroomBrand> | null;
showPoweredByBanner?: boolean;
showAccountCreationSlide?: boolean;
useAdvancedExcelViewer?: boolean;
viewerEmail?: string;
dataroomId?: string;
}) {
+ const { isMobile } = useMediaQuery();
+
+ const navData: TNavData = {
+ viewId: viewData.viewId,
+ isPreview: viewData.isPreview,
+ linkId: link.id,
+ brand: brand,
+ viewerId: "viewerId" in viewData ? viewData.viewerId : undefined,
+ isMobile: isMobile,
+ isDataroom: !!dataroomId,
+ documentId: document.id,
+ dataroomId: dataroomId,
+ conversationsEnabled:
+ !!dataroomId &&
+ ("conversationsEnabled" in viewData
+ ? viewData.conversationsEnabled
+ : false),
+ assistantEnabled: document.assistantEnabled,
+ allowDownload: link.allowDownload ?? false,
+ };
+
return notionData?.recordMap ? (
<NotionPage
recordMap={notionData.recordMap}
- // rootPageId={notionData.rootNotionPageId}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- linkId={link.id}
- documentId={document.id}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
theme={notionData.theme}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : document.downloadOnly ? (
<DownloadOnlyViewer
- file={viewData.file!}
- linkId={link.id}
- viewId={viewData.viewId}
- documentId={document.id}
- allowDownload={true}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
documentName={document.name}
- isPreview={viewData.isPreview}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : viewData.fileType === "sheet" && viewData.sheetData ? (
<ExcelViewer
- linkId={link.id}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- documentId={document.id}
- documentName={document.name}
versionNumber={document.versions[0].versionNumber}
sheetData={viewData.sheetData}
- brand={brand}
- allowDownload={link.allowDownload!}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : viewData.fileType === "sheet" && useAdvancedExcelViewer ? (
<AdvancedExcelViewer
- linkId={link.id}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- documentId={document.id}
- documentName={document.name}
- versionNumber={document.versions[0].versionNumber}
file={viewData.file!}
- allowDownload={link.allowDownload!}
- brand={brand}
- dataroomId={dataroomId}
+ versionNumber={document.versions[0].versionNumber}
+ navData={navData}
/>
) : viewData.fileType === "image" ? (
<ImageViewer
file={viewData.file!}
- linkId={link.id}
- documentId={document.id}
- viewId={viewData.viewId}
- assistantEnabled={document.assistantEnabled}
- allowDownload={link.allowDownload!}
- feedbackEnabled={link.enableFeedback!}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
showPoweredByBanner={showPoweredByBanner}
- showAccountCreationSlide={showAccountCreationSlide}
- enableQuestion={link.enableQuestion}
- feedback={link.feedback}
viewerEmail={viewerEmail}
watermarkConfig={
link.enableWatermark ? (link.watermarkConfig as WatermarkConfig) : null
}
ipAddress={viewData.ipAddress}
linkName={link.name ?? `Link #${link.id.slice(-5)}`}
- isPreview={viewData.isPreview}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : viewData.pages && !document.versions[0].isVertical ? (
<PagesHorizontalViewer
pages={viewData.pages}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- linkId={link.id}
- documentId={document.id}
- assistantEnabled={document.assistantEnabled}
- allowDownload={link.allowDownload!}
feedbackEnabled={link.enableFeedback!}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
showPoweredByBanner={showPoweredByBanner}
showAccountCreationSlide={showAccountCreationSlide}
enableQuestion={link.enableQuestion}
@@ -159,23 +143,15 @@ export default function ViewData({
}
ipAddress={viewData.ipAddress}
linkName={link.name ?? `Link #${link.id.slice(-5)}`}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : viewData.pages && document.versions[0].isVertical ? (
<PagesVerticalViewer
pages={viewData.pages}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- linkId={link.id}
- documentId={document.id}
- assistantEnabled={document.assistantEnabled}
- allowDownload={link.allowDownload!}
feedbackEnabled={link.enableFeedback!}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
showPoweredByBanner={showPoweredByBanner}
- showAccountCreationSlide={showAccountCreationSlide}
enableQuestion={link.enableQuestion}
feedback={link.feedback}
viewerEmail={viewerEmail}
@@ -184,34 +160,21 @@ export default function ViewData({
}
ipAddress={viewData.ipAddress}
linkName={link.name ?? `Link #${link.id.slice(-5)}`}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : viewData.fileType === "video" ? (
<VideoViewer
file={viewData.file!}
- linkId={link.id}
- viewId={viewData.viewId}
- documentId={document.id}
- documentName={document.name}
- allowDownload={link.allowDownload!}
screenshotProtectionEnabled={link.enableScreenshotProtection!}
versionNumber={document.versions[0].versionNumber}
- brand={brand}
- isPreview={viewData.isPreview}
- dataroomId={dataroomId}
+ navData={navData}
/>
) : (
<PDFViewer
file={viewData.file}
- viewId={viewData.viewId}
- isPreview={viewData.isPreview}
- linkId={link.id}
- documentId={document.id}
name={document.name}
- allowDownload={link.allowDownload}
- assistantEnabled={document.assistantEnabled}
versionNumber={document.versions[0].versionNumber}
- dataroomId={dataroomId}
+ navData={navData}
/>
);
}
diff --git a/components/view/viewer/advanced-excel-viewer.tsx b/components/view/viewer/advanced-excel-viewer.tsx
index ef036ce6..02af2246 100644
--- a/components/view/viewer/advanced-excel-viewer.tsx
+++ b/components/view/viewer/advanced-excel-viewer.tsx
@@ -1,9 +1,6 @@
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useRef } from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
-
-import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
const trackPageView = async (data: {
linkId: string;
@@ -29,34 +26,17 @@ const trackPageView = async (data: {
export default function AdvancedExcelViewer({
file,
- viewId,
- linkId,
- documentId,
- documentName,
- allowDownload,
versionNumber,
- brand,
- dataroomId,
- setDocumentData,
- isPreview,
+ navData,
}: {
- linkId: string;
- viewId?: string;
- documentId: string;
- documentName: string;
- versionNumber: number;
file: string;
- allowDownload: boolean;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
- isPreview?: boolean;
+ versionNumber: number;
+ navData: TNavData;
}) {
- const [pageNumber, setPageNumber] = useState<number>(1); // start on first page
- const [maxScrollPercentage, setMaxScrollPercentage] = useState<number>(0);
+ const { linkId, documentId, viewId, isPreview, dataroomId, brand } = navData;
+ const pageNumber = 1;
const startTimeRef = useRef(Date.now());
- const pageNumberRef = useRef<number>(pageNumber);
const visibilityRef = useRef<boolean>(true);
useEffect(() => {
@@ -104,18 +84,7 @@ export default function AdvancedExcelViewer({
return (
<>
- <Nav
- brand={brand}
- documentName={documentName}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- type="sheet"
- isPreview={isPreview}
- allowDownload={allowDownload}
- linkId={linkId}
- documentId={documentId}
- viewId={viewId}
- />
+ <Nav type="sheet" navData={navData} />
<div
style={{ height: "calc(100dvh - 64px)" }}
className="relative mx-2 flex h-screen flex-col sm:mx-6 lg:mx-8"
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index 777822ac..756ebc83 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -9,6 +9,8 @@ import {
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { PanelLeftIcon, XIcon } from "lucide-react";
+import { cn } from "@/lib/utils";
+
import { ViewFolderTree } from "@/components/datarooms/folders";
import {
Breadcrumb,
@@ -26,8 +28,7 @@ import {
SheetTrigger,
} from "@/components/ui/sheet";
-import { cn } from "@/lib/utils";
-
+import { DEFAULT_DATAROOM_VIEW_TYPE } from "../dataroom/dataroom-view";
import DocumentCard from "../dataroom/document-card";
import FolderCard from "../dataroom/folder-card";
import DataroomNav from "../dataroom/nav-dataroom";
@@ -82,6 +83,7 @@ export default function DataroomViewer({
setFolderId,
accessControls,
viewerId,
+ viewData,
}: {
brand: Partial<DataroomBrand>;
viewId?: string;
@@ -93,6 +95,7 @@ export default function DataroomViewer({
setFolderId: React.Dispatch<React.SetStateAction<string | null>>;
accessControls: ViewerGroupAccessControls[];
viewerId?: string;
+ viewData: DEFAULT_DATAROOM_VIEW_TYPE;
}) {
const { documents, folders } = dataroom as {
documents: DataroomDocument[];
@@ -164,7 +167,7 @@ export default function DataroomViewer({
isPreview={isPreview}
dataroomId={dataroom?.id}
viewerId={viewerId}
- conversationsEnabled={true} // TODO: update this with real value
+ conversationsEnabled={viewData.conversationsEnabled}
/>
<div
style={{ height: "calc(100vh - 64px)" }}
diff --git a/components/view/viewer/download-only-viewer.tsx b/components/view/viewer/download-only-viewer.tsx
index 76fa7d60..3461ad19 100644
--- a/components/view/viewer/download-only-viewer.tsx
+++ b/components/view/viewer/download-only-viewer.tsx
@@ -9,7 +9,7 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
const trackPageView = async (data: {
linkId: string;
@@ -34,34 +34,21 @@ const trackPageView = async (data: {
};
export default function DownloadOnlyViewer({
- file,
- linkId,
- documentId,
- viewId,
- allowDownload,
versionNumber,
- brand,
documentName,
- isPreview,
- dataroomId,
- setDocumentData,
+ navData,
}: {
- file: string;
- linkId: string;
- documentId: string;
- viewId?: string;
- allowDownload: boolean;
versionNumber: number;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
documentName?: string;
- isPreview?: boolean;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
+ navData: TNavData;
}) {
const router = useRouter();
const startTimeRef = useRef(Date.now());
const visibilityRef = useRef<boolean>(true);
+ const { linkId, documentId, viewId, isPreview, allowDownload, dataroomId } =
+ navData;
+
useEffect(() => {
// Remove token and email query parameters on component mount
const removeQueryParams = (queries: string[]) => {
@@ -163,19 +150,7 @@ export default function DownloadOnlyViewer({
return (
<>
- <Nav
- pageNumber={1}
- numPages={1}
- allowDownload={allowDownload}
- brand={brand}
- viewId={viewId}
- linkId={linkId}
- documentId={documentId}
- documentName={documentName}
- isPreview={isPreview}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- />
+ <Nav pageNumber={1} numPages={1} navData={navData} />
<div
style={{ height: "calc(100dvh - 64px)" }}
className="relative flex flex-col items-center justify-center bg-gray-50 dark:bg-gray-900"
diff --git a/components/view/viewer/excel-viewer.tsx b/components/view/viewer/excel-viewer.tsx
index 6b88f01f..409657b3 100644
--- a/components/view/viewer/excel-viewer.tsx
+++ b/components/view/viewer/excel-viewer.tsx
@@ -4,13 +4,13 @@ import React from "react";
import "@/public/vendor/handsontable/handsontable.full.min.css";
import { Brand, DataroomBrand } from "@prisma/client";
-import { Button } from "@/components/ui/button";
-
import { cn } from "@/lib/utils";
+import { Button } from "@/components/ui/button";
+
import { ScreenProtector } from "../ScreenProtection";
import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
// Define the type for the JSON data
type RowData = { [key: string]: any };
@@ -43,31 +43,15 @@ const trackPageView = async (data: {
};
export default function ExcelViewer({
- linkId,
- viewId,
- documentId,
- documentName,
versionNumber,
sheetData,
- allowDownload,
screenshotProtectionEnabled,
- brand,
- dataroomId,
- setDocumentData,
- isPreview,
+ navData,
}: {
- linkId: string;
- viewId?: string;
- documentId: string;
- documentName: string;
versionNumber: number;
sheetData: SheetData[];
- allowDownload: boolean;
screenshotProtectionEnabled: boolean;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
- isPreview?: boolean;
+ navData: TNavData;
}) {
const [availableWidth, setAvailableWidth] = useState<number>(200);
const [availableHeight, setAvailableHeight] = useState<number>(200);
@@ -76,6 +60,8 @@ export default function ExcelViewer({
const [isWindowFocused, setIsWindowFocused] = useState(true);
+ const { linkId, documentId, viewId, isPreview, dataroomId } = navData;
+
useEffect(() => {
const script = document.createElement("script");
script.src =
@@ -153,6 +139,7 @@ export default function ExcelViewer({
pageNumber: selectedSheetIndex + 1,
versionNumber,
dataroomId,
+ isPreview,
});
}
};
@@ -170,6 +157,7 @@ export default function ExcelViewer({
pageNumber: selectedSheetIndex + 1,
versionNumber,
dataroomId,
+ isPreview,
}); // Also capture duration if component unmounts while visible
startTimeRef.current = Date.now();
}
@@ -190,6 +178,7 @@ export default function ExcelViewer({
pageNumber: selectedSheetIndex + 1,
versionNumber,
dataroomId,
+ isPreview,
});
};
@@ -242,18 +231,7 @@ export default function ExcelViewer({
return (
<>
- <Nav
- brand={brand}
- documentName={documentName}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- type="sheet"
- isPreview={isPreview}
- allowDownload={allowDownload}
- linkId={linkId}
- documentId={documentId}
- viewId={viewId}
- />
+ <Nav type="sheet" navData={navData} />
<div
style={{ height: "calc(100dvh - 64px)" }}
className={cn(
diff --git a/components/view/viewer/image-viewer.tsx b/components/view/viewer/image-viewer.tsx
index d4c82ba2..9a660539 100644
--- a/components/view/viewer/image-viewer.tsx
+++ b/components/view/viewer/image-viewer.tsx
@@ -3,20 +3,16 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
import React from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
-
import { WatermarkConfig } from "@/lib/types";
import { cn } from "@/lib/utils";
-import { useMediaQuery } from "@/lib/utils/use-media-query";
-
-import "@/styles/custom-viewer-styles.css";
import { ScreenProtector } from "../ScreenProtection";
-import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
import { PoweredBy } from "../powered-by";
import { SVGWatermark } from "../watermark-svg";
+import "@/styles/custom-viewer-styles.css";
+
const trackPageView = async (data: {
linkId: string;
documentId: string;
@@ -41,56 +37,29 @@ const trackPageView = async (data: {
export default function ImageViewer({
file,
- linkId,
- documentId,
- viewId,
- assistantEnabled,
- allowDownload,
- feedbackEnabled,
screenshotProtectionEnabled,
versionNumber,
- brand,
- documentName,
- dataroomId,
- setDocumentData,
showPoweredByBanner,
- showAccountCreationSlide,
- enableQuestion = false,
- feedback,
viewerEmail,
- isPreview,
watermarkConfig,
ipAddress,
linkName,
+ navData,
}: {
file: string;
- linkId: string;
- documentId: string;
- viewId?: string;
- assistantEnabled?: boolean;
- allowDownload: boolean;
- feedbackEnabled: boolean;
screenshotProtectionEnabled: boolean;
versionNumber: number;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- documentName?: string;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
showPoweredByBanner?: boolean;
- showAccountCreationSlide?: boolean;
- enableQuestion?: boolean | null;
- feedback?: {
- id: string;
- data: { question: string; type: string };
- } | null;
viewerEmail?: string;
- isPreview?: boolean;
watermarkConfig?: WatermarkConfig | null;
ipAddress?: string;
linkName?: string;
+ navData: TNavData;
}) {
const router = useRouter();
+ const { isPreview, linkId, documentId, viewId, dataroomId } = navData;
+
const numPages = 1;
const [pageNumber, setPageNumber] = useState<number>(1); // start on first page
@@ -108,8 +77,6 @@ export default function ImageViewer({
height: number;
} | null>(null);
- const { isMobile } = useMediaQuery();
-
// Add zoom handlers
const handleZoomIn = () => {
setScale((prev) => Math.min(prev + 0.25, 3)); // Max zoom 3x
@@ -278,19 +245,10 @@ export default function ImageViewer({
<Nav
pageNumber={pageNumber}
numPages={numPages}
- allowDownload={allowDownload}
- brand={brand}
- viewId={viewId}
- linkId={linkId}
- documentId={documentId}
- documentName={documentName}
- isDataroom={!!dataroomId}
- setDocumentData={setDocumentData}
- isMobile={isMobile}
- isPreview={isPreview}
hasWatermark={!!watermarkConfig}
handleZoomIn={handleZoomIn}
handleZoomOut={handleZoomOut}
+ navData={navData}
/>
<div
style={{ height: "calc(100dvh - 64px)" }}
diff --git a/components/view/viewer/pages-horizontal-viewer.tsx b/components/view/viewer/pages-horizontal-viewer.tsx
index 751153fd..0882d2a7 100644
--- a/components/view/viewer/pages-horizontal-viewer.tsx
+++ b/components/view/viewer/pages-horizontal-viewer.tsx
@@ -3,25 +3,22 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
import React from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
import { useSession } from "next-auth/react";
import { WatermarkConfig } from "@/lib/types";
import { cn } from "@/lib/utils";
-import { useMediaQuery } from "@/lib/utils/use-media-query";
-
-import "@/styles/custom-viewer-styles.css";
import { ScreenProtector } from "../ScreenProtection";
-import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
import { PoweredBy } from "../powered-by";
import Question from "../question";
import Toolbar from "../toolbar";
import ViewDurationSummary from "../visitor-graph";
import { SVGWatermark } from "../watermark-svg";
+import "@/styles/custom-viewer-styles.css";
+
const DEFAULT_PRELOADED_IMAGES_NUM = 5;
const trackPageView = async (data: {
@@ -60,27 +57,18 @@ const trackPageView = async (data: {
export default function PagesHorizontalViewer({
pages,
- linkId,
- documentId,
- viewId,
- assistantEnabled,
- allowDownload,
feedbackEnabled,
screenshotProtectionEnabled,
versionNumber,
- brand,
- documentName,
- dataroomId,
- setDocumentData,
showPoweredByBanner,
showAccountCreationSlide,
enableQuestion = false,
feedback,
viewerEmail,
- isPreview,
watermarkConfig,
ipAddress,
linkName,
+ navData,
}: {
pages: {
file: string;
@@ -89,18 +77,9 @@ export default function PagesHorizontalViewer({
pageLinks: { href: string; coords: string }[];
metadata: { width: number; height: number; scaleFactor: number };
}[];
- linkId: string;
- documentId: string;
- viewId?: string;
- assistantEnabled?: boolean;
- allowDownload: boolean;
feedbackEnabled: boolean;
screenshotProtectionEnabled: boolean;
versionNumber: number;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- documentName?: string;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
showPoweredByBanner?: boolean;
showAccountCreationSlide?: boolean;
enableQuestion?: boolean | null;
@@ -109,11 +88,14 @@ export default function PagesHorizontalViewer({
data: { question: string; type: string };
} | null;
viewerEmail?: string;
- isPreview?: boolean;
watermarkConfig?: WatermarkConfig | null;
ipAddress?: string;
linkName?: string;
+ navData: TNavData;
}) {
+ const { isMobile, isPreview, linkId, documentId, viewId, dataroomId } =
+ navData;
+
const router = useRouter();
const { status: sessionStatus } = useSession();
@@ -167,8 +149,6 @@ export default function PagesHorizontalViewer({
Record<number, { width: number; height: number }>
>({});
- const { isMobile } = useMediaQuery();
-
const scaleCoordinates = (coords: string, scaleFactor: number) => {
return coords
.split(",")
@@ -540,29 +520,16 @@ export default function PagesHorizontalViewer({
return () => window.removeEventListener("keydown", handleKeyDown);
}, [containerRef.current, pageNumber, imageDimensions]);
- const [showLeftArrow, setShowLeftArrow] = useState(false);
- const [showRightArrow, setShowRightArrow] = useState(false);
-
return (
<>
<Nav
pageNumber={pageNumber}
numPages={numPagesWithAccountCreation}
- assistantEnabled={assistantEnabled}
- allowDownload={allowDownload}
- brand={brand}
- viewId={viewId}
- linkId={linkId}
- documentId={documentId}
- documentName={documentName}
embeddedLinks={pages[pageNumber - 1]?.embeddedLinks}
- isDataroom={!!dataroomId}
- setDocumentData={setDocumentData}
- isMobile={isMobile}
- isPreview={isPreview}
hasWatermark={!!watermarkConfig}
handleZoomIn={handleZoomIn}
handleZoomOut={handleZoomOut}
+ navData={navData}
/>
<div
style={{ height: "calc(100dvh - 64px)" }}
diff --git a/components/view/viewer/pages-vertical-viewer.tsx b/components/view/viewer/pages-vertical-viewer.tsx
index 3438bc22..a734dc1e 100644
--- a/components/view/viewer/pages-vertical-viewer.tsx
+++ b/components/view/viewer/pages-vertical-viewer.tsx
@@ -3,23 +3,21 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
import React from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
import { ChevronDownIcon, ChevronUpIcon } from "lucide-react";
import { WatermarkConfig } from "@/lib/types";
import { cn } from "@/lib/utils";
import { useMediaQuery } from "@/lib/utils/use-media-query";
-import "@/styles/custom-viewer-styles.css";
-
import { ScreenProtector } from "../ScreenProtection";
-import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
import { PoweredBy } from "../powered-by";
import Question from "../question";
import Toolbar from "../toolbar";
import { SVGWatermark } from "../watermark-svg";
+import "@/styles/custom-viewer-styles.css";
+
const DEFAULT_PRELOADED_IMAGES_NUM = 5;
const calculateOptimalWidth = (
@@ -85,27 +83,17 @@ const trackPageView = async (data: {
export default function PagesVerticalViewer({
pages,
- linkId,
- documentId,
- viewId,
- assistantEnabled,
- allowDownload,
feedbackEnabled,
screenshotProtectionEnabled,
versionNumber,
- brand,
- documentName,
- dataroomId,
- setDocumentData,
showPoweredByBanner,
- showAccountCreationSlide,
enableQuestion = false,
feedback,
viewerEmail,
- isPreview,
watermarkConfig,
ipAddress,
linkName,
+ navData,
}: {
pages: {
file: string;
@@ -114,31 +102,23 @@ export default function PagesVerticalViewer({
pageLinks: { href: string; coords: string }[];
metadata: { width: number; height: number; scaleFactor: number };
}[];
- linkId: string;
- documentId: string;
- viewId?: string;
- assistantEnabled?: boolean;
- allowDownload: boolean;
feedbackEnabled: boolean;
screenshotProtectionEnabled: boolean;
versionNumber: number;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- documentName?: string;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
showPoweredByBanner?: boolean;
- showAccountCreationSlide?: boolean;
enableQuestion?: boolean | null;
feedback?: {
id: string;
data: { question: string; type: string };
} | null;
viewerEmail?: string;
- isPreview?: boolean;
watermarkConfig?: WatermarkConfig | null;
ipAddress?: string;
linkName?: string;
+ navData: TNavData;
}) {
+ const { linkId, documentId, viewId, isPreview, dataroomId } = navData;
+
const router = useRouter();
const numPages = pages.length;
@@ -697,21 +677,11 @@ export default function PagesVerticalViewer({
<Nav
pageNumber={pageNumber}
numPages={numPagesWithAccountCreation}
- assistantEnabled={assistantEnabled}
- allowDownload={allowDownload}
- brand={brand}
- viewId={viewId}
- linkId={linkId}
- documentId={documentId}
- documentName={documentName}
embeddedLinks={pages[pageNumber - 1]?.embeddedLinks}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- isMobile={isMobile}
- isPreview={isPreview}
hasWatermark={watermarkConfig ? true : false}
handleZoomIn={handleZoomIn}
handleZoomOut={handleZoomOut}
+ navData={navData}
/>
<div
style={{ height: "calc(100dvh - 64px)" }}
diff --git a/components/view/viewer/video-viewer.tsx b/components/view/viewer/video-viewer.tsx
index 2fa6c09f..a2a9be10 100644
--- a/components/view/viewer/video-viewer.tsx
+++ b/components/view/viewer/video-viewer.tsx
@@ -1,43 +1,28 @@
import { useEffect, useRef, useState } from "react";
-import { Brand, DataroomBrand } from "@prisma/client";
import { toast } from "sonner";
import { createVideoTracker } from "@/lib/tracking/video-tracking";
import { cn } from "@/lib/utils";
import { ScreenProtector } from "../ScreenProtection";
-import { TDocumentData } from "../dataroom/dataroom-view";
-import Nav from "../nav";
+import Nav, { TNavData } from "../nav";
import { VideoPlayer } from "./video-player";
export default function VideoViewer({
file,
- linkId,
- documentId,
- viewId,
- documentName,
- allowDownload,
screenshotProtectionEnabled,
versionNumber,
- brand,
- dataroomId,
- setDocumentData,
- isPreview,
+ navData,
}: {
file: string;
- linkId: string;
- documentId: string;
- viewId?: string;
- documentName: string;
- allowDownload: boolean;
screenshotProtectionEnabled: boolean;
versionNumber: number;
- brand?: Partial<Brand> | Partial<DataroomBrand> | null;
- dataroomId?: string;
- setDocumentData?: React.Dispatch<React.SetStateAction<TDocumentData | null>>;
- isPreview?: boolean;
+ navData: TNavData;
}) {
+ const { isPreview, linkId, documentId, viewId, dataroomId, allowDownload } =
+ navData;
+
const videoRef = useRef<HTMLVideoElement>(null);
const [isWindowFocused, setIsWindowFocused] = useState(true);
const videoTrackerRef = useRef<ReturnType<typeof createVideoTracker> | null>(
@@ -113,17 +98,7 @@ export default function VideoViewer({
return (
<>
- <Nav
- brand={brand}
- documentName={documentName}
- isDataroom={dataroomId ? true : false}
- setDocumentData={setDocumentData}
- isPreview={isPreview}
- allowDownload={allowDownload}
- linkId={linkId}
- documentId={documentId}
- viewId={viewId}
- />
+ <Nav navData={navData} />
<div
style={{ height: "calc(100dvh - 64px)" }}
className={cn(