Skip to content

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

Resolved the conficits

Vinod Pal2ceb94467694
diff --cc components/view/document-view.tsx
index 11419424,d10e7f53..76f1b168
--- a/components/view/document-view.tsx
+++ b/components/view/document-view.tsx
@@@ -20,7 -21,8 +21,8 @@@ export type DEFAULT_ACCESS_FORM_TYPE =
export type DEFAULT_DOCUMENT_VIEW_TYPE = {
viewId: string;
- file: string;
+ file: string | null;
- pages: {file: string, pageNumber: string}[] | null;
++ pages: { file: string; pageNumber: string }[] | null;
};
export default function DocumentView({
@@@ -127,49 -128,23 +128,25 @@@
handleSubmission();
}
- // get the file extension
- const extension = getExtension(viewData.file);
-
- if (
- extension.includes(".docx") ||
- extension.includes(".pptx") ||
- extension.includes(".xlsx") ||
- extension.includes(".xls") ||
- extension.includes(".doc") ||
- extension.includes(".ppt")
- ) {
- return (
- <div className="h-screen bg-gray-900">
- <iframe
- className="w-full h-full"
- src={`https://view.officeapps.live.com/op/embed.aspx?src=${viewData.file}`}
- ></iframe>
- </div>
- );
- }
-
- if (
- extension.includes(".png") ||
- extension.includes(".jpeg") ||
- extension.includes(".gif") ||
- extension.includes(".jpg")
- ) {
- return (
- <div className="h-screen bg-gray-900">
- <img className="w-full h-full" src={viewData.file} />
- </div>
- );
- }
return (
<div className="bg-gray-950">
- <PDFViewer
- file={viewData.file}
- viewId={viewData.viewId}
- linkId={link.id}
- documentId={document.id}
- name={document.name}
- allowDownload={link.allowDownload}
- />
+ {viewData.pages ? (
+ <PagesViewer
+ pages={viewData.pages}
+ viewId={viewData.viewId}
+ linkId={link.id}
+ documentId={document.id}
+ />
+ ) : (
+ <PDFViewer
+ file={viewData.file}
+ viewId={viewData.viewId}
+ linkId={link.id}
+ documentId={document.id}
++ name={document.name}
++ allowDownload={link.allowDownload}
+ />
+ )}
</div>
);
}
diff --cc prisma/schema.prisma
index 574d6e31,38e071c6..bf56b0c5
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@@ -64,18 -64,48 +64,48 @@@ model VerificationToken
}
model Document {
- id String @id @default(cuid())
- id String @id @default(cuid())
- name String
++ id String @id @default(cuid())
+ name String
description String?
- file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
- type String? // This should be a reference to the file type (pdf, docx, etc.)
- numPages Int? // This should be a reference to the number of pages in the document
- owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
- ownerId String // This field holds the foreign key.
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- links Link[]
- views View[]
- versions DocumentVersion[]
+ file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
+ type String? // This should be a reference to the file type (pdf, docx, etc.)
+ numPages Int? // This should be a reference to the number of pages in the document
- owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
++ owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
+ ownerId String // This field holds the foreign key.
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
++ createdAt DateTime @default(now())
++ updatedAt DateTime @updatedAt
+ links Link[]
+ views View[]
++ versions DocumentVersion[]
+ }
+
+ model DocumentVersion {
- id String @id @default(cuid())
- versionNumber Int // e.g., 1, 2, 3 for version control
- document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
- documentId String
- file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
- type String? // This should be a reference to the file type (pdf, docx, etc.)
- numPages Int? // This should be a reference to the number of pages in the document
- isPrimary Boolean @default(false) // Indicates if this is the primary version
- pages DocumentPage[]
- hasPages Boolean @default(false) // Indicates if the document has pages
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
++ id String @id @default(cuid())
++ versionNumber Int // e.g., 1, 2, 3 for version control
++ document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
++ documentId String
++ file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
++ type String? // This should be a reference to the file type (pdf, docx, etc.)
++ numPages Int? // This should be a reference to the number of pages in the document
++ isPrimary Boolean @default(false) // Indicates if this is the primary version
++ pages DocumentPage[]
++ hasPages Boolean @default(false) // Indicates if the document has pages
++ createdAt DateTime @default(now())
++ updatedAt DateTime @updatedAt
+
+ @@unique([versionNumber, documentId])
+ }
+
+ model DocumentPage {
- id String @id @default(cuid())
- version DocumentVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
- versionId String
- pageNumber Int // e.g., 1, 2, 3 for
- file String // This should be a reference to where the file / page is stored (S3, Google Cloud Storage, etc.)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
++ id String @id @default(cuid())
++ version DocumentVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
++ versionId String
++ pageNumber Int // e.g., 1, 2, 3 for
++ file String // This should be a reference to where the file / page is stored (S3, Google Cloud Storage, etc.)
++ createdAt DateTime @default(now())
++ updatedAt DateTime @updatedAt
+
+ @@unique([pageNumber, versionId])
}
model Link {