Skip to content

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

feat: add agreement in visitor table

Marc Seitz6cedb49f2e9c
diff --git a/components/view/access-form/agreement-section.tsx b/components/view/access-form/agreement-section.tsx
index 265bee2d..b6c7fbf3 100644
--- a/components/view/access-form/agreement-section.tsx
+++ b/components/view/access-form/agreement-section.tsx
@@ -25,7 +25,7 @@ export default function AgreementSection({
onCheckedChange={handleCheckChange}
className="mt-0.5 border border-gray-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-300 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-white data-[state=checked]:bg-black data-[state=checked]:text-white"
/>
- <label className="text-sm font-medium leading-5 text-white peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
+ <label className="text-sm font-normal leading-5 text-white peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
I have reviewed and agree to the terms of this{" "}
<a
href={`${agreementContent}`}
diff --git a/components/visitors/dataroom-visitors-table.tsx b/components/visitors/dataroom-visitors-table.tsx
index ec593a35..39415c57 100644
--- a/components/visitors/dataroom-visitors-table.tsx
+++ b/components/visitors/dataroom-visitors-table.tsx
@@ -1,4 +1,9 @@
-import { BadgeCheckIcon, BadgeInfoIcon, MailOpenIcon } from "lucide-react";
+import {
+ BadgeCheckIcon,
+ BadgeInfoIcon,
+ FileBadgeIcon,
+ MailOpenIcon,
+} from "lucide-react";
import ChevronDown from "@/components/shared/icons/chevron-down";
import {
@@ -87,6 +92,14 @@ export default function DataroomVisitorsTable({
<BadgeInfoIcon className="h-4 w-4 text-blue-500 hover:text-blue-600" />
</BadgeTooltip>
)}
+ {view.agreementResponse && (
+ <BadgeTooltip
+ content={`Agreed to ${view.agreementResponse.agreement.name}`}
+ key="nda-agreement"
+ >
+ <FileBadgeIcon className="h-4 w-4 text-emerald-500 hover:text-emerald-600" />
+ </BadgeTooltip>
+ )}
</>
) : (
"Anonymous"
diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsx
index 33206c29..1ba99c9b 100644
--- a/components/visitors/visitors-table.tsx
+++ b/components/visitors/visitors-table.tsx
@@ -5,6 +5,7 @@ import {
BadgeCheckIcon,
BadgeInfoIcon,
DownloadCloudIcon,
+ FileBadgeIcon,
ServerIcon,
ThumbsDownIcon,
ThumbsUpIcon,
@@ -112,6 +113,14 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {
<BadgeInfoIcon className="h-4 w-4 text-blue-500 hover:text-blue-600" />
</BadgeTooltip>
)}
+ {view.agreementResponse && (
+ <BadgeTooltip
+ content={`Agreed to ${view.agreementResponse.agreement.name}`}
+ key="nda-agreement"
+ >
+ <FileBadgeIcon className="h-4 w-4 text-emerald-500 hover:text-emerald-600" />
+ </BadgeTooltip>
+ )}
{view.downloadedAt && (
<BadgeTooltip
content={`Downloaded ${timeAgo(view.downloadedAt)}`}
diff --git a/lib/swr/use-document.ts b/lib/swr/use-document.ts
index 399ad330..593c36f4 100644
--- a/lib/swr/use-document.ts
+++ b/lib/swr/use-document.ts
@@ -80,6 +80,13 @@ interface ViewWithDuration extends View {
answer: string;
};
} | null;
+ agreementResponse: {
+ id: string;
+ agreementId: string;
+ agreement: {
+ name: string;
+ };
+ } | null;
}
type TStatsData = {
@@ -99,9 +106,7 @@ export function useDocumentVisits(page: number, limit: number) {
const cacheKey =
teamId && id
- ? `/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(
- id,
- )}/views?page=${page}&limit=${limit}`
+ ? `/api/teams/${teamId}/documents/${id}/views?page=${page}&limit=${limit}`
: null;
const { data: views, error } = useSWR<TStatsData>(cacheKey, fetcher, {
@@ -124,9 +129,11 @@ interface DocumentProcessingStatus {
export function useDocumentProcessingStatus(documentVersionId: string) {
const teamInfo = useTeam();
+ const teamId = teamInfo?.currentTeam?.id;
const { data: status, error } = useSWR<DocumentProcessingStatus>(
- `/api/teams/${teamInfo?.currentTeam?.id}/documents/document-processing-status?documentVersionId=${documentVersionId}`,
+ teamId &&
+ `/api/teams/${teamId}/documents/document-processing-status?documentVersionId=${documentVersionId}`,
fetcher,
{
refreshInterval: 3000, // refresh every 3 seconds
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/views/index.ts b/pages/api/teams/[teamId]/datarooms/[id]/views/index.ts
index 21a7a983..6e08c7cd 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/views/index.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/views/index.ts
@@ -66,6 +66,17 @@ export default async function handle(
name: true,
},
},
+ agreementResponse: {
+ select: {
+ id: true,
+ agreementId: true,
+ agreement: {
+ select: {
+ name: true,
+ },
+ },
+ },
+ },
},
},
},
diff --git a/pages/api/teams/[teamId]/documents/[id]/views/index.ts b/pages/api/teams/[teamId]/documents/[id]/views/index.ts
index 321b30b4..b24a913b 100644
--- a/pages/api/teams/[teamId]/documents/[id]/views/index.ts
+++ b/pages/api/teams/[teamId]/documents/[id]/views/index.ts
@@ -95,6 +95,17 @@ export default async function handle(
data: true,
},
},
+ agreementResponse: {
+ select: {
+ id: true,
+ agreementId: true,
+ agreement: {
+ select: {
+ name: true,
+ },
+ },
+ },
+ },
},
});