Skip to content

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

Merge branch 'main' into feat/verify-email-to-view-document

Marc Seitzea90066f77ab
diff --cc components/links/link-sheet/index.tsx
index 19e8eb42,cdd300bd..52cab4fe
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@@ -24,8 -24,11 +24,12 @@@ import Link from "next/link"
import DomainSection from "./domain-section";
import AllowDownloadSection from "./allow-download-section";
import { useTeam } from "@/context/team-context";
- import AllowNotificationSection from "./allow-notification";
+import EmailAuthenticationSection from "./email-authentication-section";
+ import AllowNotificationSection from "./allow-notification-section";
+ import FeedbackSection from "./feedback-section";
+ import OGSection from "./og-section";
+ import { ScrollArea } from "@/components/ui/scroll-area";
+ import { upload } from "@vercel/blob/client";
export const DEFAULT_LINK_PROPS = {
id: null,
@@@ -35,9 -38,13 +39,14 @@@
expiresAt: null,
password: null,
emailProtected: true,
+ emailAuthenticated: false,
allowDownload: false,
enableNotification: true,
+ enableFeedback: true,
+ enableCustomMetatag: false,
+ metaTitle: null,
+ metaDescription: null,
+ metaImage: null,
};
export type DEFAULT_LINK_TYPE = {
@@@ -48,9 -55,13 +57,14 @@@
expiresAt: Date | null;
password: string | null;
emailProtected: boolean;
+ emailAuthenticated: boolean;
allowDownload: boolean;
enableNotification: boolean;
+ enableFeedback: boolean;
+ enableCustomMetatag: boolean; // metatags
+ metaTitle: string | null; // metatags
+ metaDescription: string | null; // metatags
+ metaImage: string | null; // metatags
};
export default function LinkSheet({
@@@ -154,48 -177,52 +180,53 @@@
done.
</SheetDescription>
</SheetHeader>
+
<form className="flex flex-col grow" onSubmit={handleSubmit}>
- <div className="h-0 flex-1">
- <div className="flex flex-1 flex-col justify-between">
- <div className="divide-y divide-gray-200">
- <div className="space-y-6 pb-5 pt-6">
- <div className="space-y-2">
- <Label htmlFor="link-name">Link Name</Label>
- <div className="mt-2">
- <input
- type="text"
- name="link-name"
- id="link-name"
- placeholder="Recipient's Organization"
- value={data.name || ""}
- className="flex w-full rounded-md border-0 py-1.5 text-foreground bg-background shadow-sm ring-1 ring-inset ring-input placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-gray-400 sm:text-sm sm:leading-6"
- onChange={(e) =>
- setData({ ...data, name: e.target.value })
- }
- />
+ <ScrollArea className="flex-grow">
+ <div className="h-0 flex-1">
+ <div className="flex flex-1 flex-col justify-between">
+ <div className="divide-y divide-gray-200">
+ <div className="space-y-6 pb-5 pt-6">
+ <div className="space-y-2">
+ <Label htmlFor="link-name">Link Name</Label>
+ <div className="mt-2">
+ <input
+ type="text"
+ name="link-name"
+ id="link-name"
+ placeholder="Recipient's Organization"
+ value={data.name || ""}
+ className="flex w-full rounded-md border-0 py-1.5 text-foreground bg-background shadow-sm ring-1 ring-inset ring-input placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-gray-400 sm:text-sm sm:leading-6"
+ onChange={(e) =>
+ setData({ ...data, name: e.target.value })
+ }
+ />
+ </div>
</div>
- </div>
- <div className="space-y-2">
- <DomainSection {...{ data, setData, domains }} />
- </div>
+ <div className="space-y-2">
+ <DomainSection {...{ data, setData, domains }} />
+ </div>
- <div className="flex items-center relative">
- <Separator className="bg-muted-foreground absolute" />
- <div className="relative mx-auto">
- <span className="px-2 bg-background text-muted-foreground text-sm">
- Optional
- </span>
+ <div className="flex items-center relative">
+ <Separator className="bg-muted-foreground absolute" />
+ <div className="relative mx-auto">
+ <span className="px-2 bg-background text-muted-foreground text-sm">
+ Optional
+ </span>
+ </div>
</div>
- </div>
- <div>
- <EmailProtectionSection {...{ data, setData }} />
- <EmailAuthenticationSection {...{ data, setData }} />
- <AllowDownloadSection {...{ data, setData }} />
- <PasswordSection {...{ data, setData }} />
- <ExpirationSection {...{ data, setData }} />
- <AllowNotificationSection {...{ data, setData }} />
+ <div>
+ <EmailProtectionSection {...{ data, setData }} />
++ <EmailAuthenticationSection {...{ data, setData }} />
+ <AllowDownloadSection {...{ data, setData }} />
+ <PasswordSection {...{ data, setData }} />
+ <ExpirationSection {...{ data, setData }} />
+ <OGSection {...{ data, setData }} />
+ <AllowNotificationSection {...{ data, setData }} />
+ <FeedbackSection {...{ data, setData }} />
+ </div>
</div>
</div>
</div>
diff --cc components/view/document-view.tsx
index 997da414,38c7cd41..7ef27fc1
--- a/components/view/document-view.tsx
+++ b/components/view/document-view.tsx
@@@ -7,11 -7,11 +7,10 @@@ import { usePlausible } from "next-plau
import { toast } from "sonner";
import { LinkWithDocument } from "@/lib/types";
import LoadingSpinner from "@/components/ui/loading-spinner";
-import PagesViewer from "@/components/view/PagesViewer";
-import PDFViewer from "@/components/view/PDFViewer";
-import { NotionPage } from "../NotionPage";
import { ExtendedRecordMap } from "notion-types";
+import EmailVerificationMessage from "./email-verification-form";
+import ViewData from "./view-data";
- import { is } from "date-fns/locale";
- import handle from "@/pages/api/record_reaction";
+ import { Brand } from "@prisma/client";
export type DEFAULT_DOCUMENT_VIEW_TYPE = {
viewId: string;
@@@ -24,10 -24,8 +23,11 @@@ export default function DocumentView(
userEmail,
userId,
isProtected,
+ hasEmailVerification,
notionData,
+ token,
+ verifiedEmail,
+ brand,
}: {
link: LinkWithDocument;
userEmail: string | null | undefined;
@@@ -38,8 -35,7 +38,9 @@@
rootNotionPageId: string | null;
recordMap: ExtendedRecordMap | null;
};
+ token: string | undefined;
+ verifiedEmail: string | undefined;
+ brand?: Brand;
}) {
const { document, emailProtected, password: linkPassword } = link;
@@@ -123,20 -102,8 +124,19 @@@
}
}, [submitted, isProtected]);
+ // Components to render when email is submitted but verification is pending
+ if (verificationRequested) {
+ return (
+ <EmailVerificationMessage
+ onSubmitHandler={handleSubmit}
+ data={data}
+ isLoading={isLoading}
+ />
+ );
+ }
+
// If link is not submitted and does not have email / password protection, show the access form
- if (!submitted && isProtected && !token) {
- console.log("calling access form");
+ if (!submitted && isProtected) {
return (
<AccessForm
data={data}
diff --cc pages/api/links/[id]/index.ts
index e7628cc0,fe3ca648..d383dbf4
--- a/pages/api/links/[id]/index.ts
+++ b/pages/api/links/[id]/index.ts
@@@ -23,10 -23,14 +23,15 @@@ export default async function handle
id: true,
expiresAt: true,
emailProtected: true,
+ emailAuthenticated: true,
allowDownload: true,
+ enableFeedback: true,
password: true,
isArchived: true,
+ enableCustomMetatag: true,
+ metaTitle: true,
+ metaDescription: true,
+ metaImage: true,
document: {
select: {
id: true,
diff --cc pages/view/[linkId]/index.tsx
index 79c0a84a,e880f09d..073eb397
--- a/pages/view/[linkId]/index.tsx
+++ b/pages/view/[linkId]/index.tsx
@@@ -81,12 -94,15 +94,19 @@@ export default function ViewPage(
rootNotionPageId: string | null;
recordMap: ExtendedRecordMap | null;
};
+ meta: {
+ enableCustomMetatag: boolean;
+ metaTitle: string | null;
+ metaDescription: string | null;
+ metaImage: string | null;
+ } | null;
+ brand?: Brand;
}) {
const router = useRouter();
+ const { token, email: verifiedEmail } = router.query as {
+ token: string;
+ email: string;
+ };
const { data: session, status } = useSession();
if (!link || status === "loading" || router.isFallback) {
diff --cc pages/view/domains/[domain]/[slug]/index.tsx
index 3ebb0ae4,a68a1b07..63654497
--- a/pages/view/domains/[domain]/[slug]/index.tsx
+++ b/pages/view/domains/[domain]/[slug]/index.tsx
@@@ -78,16 -94,31 +92,32 @@@ export default function ViewPage(
rootNotionPageId: string | null;
recordMap: ExtendedRecordMap | null;
};
+ meta: {
+ enableCustomMetatag: boolean;
+ metaTitle: string | null;
+ metaDescription: string | null;
+ metaImage: string | null;
+ } | null;
+ brand?: Brand;
}) {
- const router = useRouter();
const { data: session, status } = useSession();
+ const router = useRouter();
+ const { authenticationCode } = router.query as { authenticationCode: string };
- if (!link || status === "loading" || router.isFallback) {
+ if (!link || status === "loading") {
return (
- <div className="h-screen flex items-center justify-center">
- <LoadingSpinner className="h-20 w-20" />
- </div>
+ <>
+ {meta && meta.enableCustomMetatag ? (
+ <CustomMetatag
+ title={meta.metaTitle}
+ description={meta.metaDescription}
+ imageUrl={meta.metaImage}
+ />
+ ) : null}
+ <div className="h-screen flex items-center justify-center">
+ <LoadingSpinner className="h-20 w-20" />
+ </div>
+ </>
);
}