Skip to content

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

feat: show feedback response in visitor table

Marc Seitz3e840bd47197
diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsx
index b6974fdb..d7d19986 100644
--- a/components/visitors/visitors-table.tsx
+++ b/components/visitors/visitors-table.tsx
@@ -24,6 +24,8 @@ import {
BadgeInfoIcon,
DownloadCloudIcon,
ServerIcon,
+ ThumbsDownIcon,
+ ThumbsUpIcon,
} from "lucide-react";
import { BadgeTooltip } from "@/components/ui/tooltip";
@@ -103,6 +105,19 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {
<ServerIcon className="h-4 w-4 text-[#fb7a00] hover:text-[#fb7a00]/90" />
</BadgeTooltip>
)}
+ {view.feedbackResponse && (
+ <BadgeTooltip
+ content={`${view.feedbackResponse.data.question}: ${view.feedbackResponse.data.answer}`}
+ key="feedback"
+ >
+ {view.feedbackResponse.data.answer ===
+ "yes" ? (
+ <ThumbsUpIcon className="h-4 w-4 text-gray-500 hover:text-gray-600" />
+ ) : (
+ <ThumbsDownIcon className="h-4 w-4 text-gray-500 hover:text-gray-600" />
+ )}
+ </BadgeTooltip>
+ )}
</>
) : (
"Anonymous"
diff --git a/lib/swr/use-document.ts b/lib/swr/use-document.ts
index d4c5d59f..95f2ee00 100644
--- a/lib/swr/use-document.ts
+++ b/lib/swr/use-document.ts
@@ -70,6 +70,13 @@ interface ViewWithDuration extends View {
link: {
name: string | null;
};
+ feedbackResponse: {
+ id: string;
+ data: {
+ question: string;
+ answer: string;
+ };
+ } | null;
}
export function useDocumentVisits() {
diff --git a/pages/api/teams/[teamId]/documents/[id]/views/index.ts b/pages/api/teams/[teamId]/documents/[id]/views/index.ts
index 4c751421..915dfda9 100644
--- a/pages/api/teams/[teamId]/documents/[id]/views/index.ts
+++ b/pages/api/teams/[teamId]/documents/[id]/views/index.ts
@@ -52,6 +52,12 @@ export default async function handle(
name: true,
},
},
+ feedbackResponse: {
+ select: {
+ id: true,
+ data: true,
+ },
+ },
},
},
},