diff --git a/components/documents/document-header.tsx b/components/documents/document-header.tsx index 3396d5ac7..c9debd2fa 100644 --- a/components/documents/document-header.tsx +++ b/components/documents/document-header.tsx @@ -27,8 +27,9 @@ import { } from "@/components/ui/dropdown-menu"; import { DocumentWithLinksAndLinkCountAndViewCount } from "@/lib/types"; -import { getExtension } from "@/lib/utils"; +import { cn, getExtension } from "@/lib/utils"; +import PortraitLandscape from "../shared/icons/portrait-landscape"; import { AddDocumentModal } from "./add-document-modal"; export default function DocumentHeader({ @@ -168,6 +169,36 @@ export default function DocumentHeader({ }); }; + const changeDocumentOrientation = async () => { + const response = await fetch( + "/api/teams/" + + teamId + + "/documents/" + + prismaDocument.id + + "/change-orientation", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + versionId: primaryVersion.id, + isVertical: primaryVersion.isVertical ? false : true, + }), + }, + ); + + if (response.ok) { + const { message } = await response.json(); + toast.success(message); + + mutate(`/api/teams/${teamId}/documents/${prismaDocument.id}`); + } else { + const { message } = await response.json(); + toast.error(message); + } + }; + useEffect(() => { function handleClickOutside(event: { target: any }) { if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { @@ -278,6 +309,19 @@ export default function DocumentHeader({
+ + {primaryVersion.type !== "notion" && (
) : null; diff --git a/components/view/dataroom/document-card.tsx b/components/view/dataroom/document-card.tsx index 52d98c383..11bbed600 100644 --- a/components/view/dataroom/document-card.tsx +++ b/components/view/dataroom/document-card.tsx @@ -38,6 +38,7 @@ type DRDocument = { type: string; versionNumber: number; hasPages: boolean; + isVertical: boolean; }[]; }; @@ -51,6 +52,7 @@ type DocumentsCardProps = { documentType: "pdf" | "notion"; documentVersionId: string; documentVersionNumber: number; + isVertical: boolean; }) => void; }; export default function DocumentCard({ @@ -94,6 +96,7 @@ export default function DocumentCard({ | "notion", documentVersionId: document.versions[0].id, documentVersionNumber: document.versions[0].versionNumber, + isVertical: document.versions[0].isVertical, }); }} className="w-full truncate" diff --git a/components/view/view-data.tsx b/components/view/view-data.tsx index 59701520c..4371b504e 100644 --- a/components/view/view-data.tsx +++ b/components/view/view-data.tsx @@ -53,6 +53,7 @@ export default function ViewData({ showPoweredByBanner={showPoweredByBanner} enableQuestion={link.enableQuestion} feedback={link.feedback} + isVertical={document.versions[0].isVertical} /> ) : (