Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
chore: prettier cleanup
Marc Seitzb57937b6896a
diff --git a/components/links/links-visitors.tsx b/components/links/links-visitors.tsxindex 5bd68741..706405f6 100644--- a/components/links/links-visitors.tsx+++ b/components/links/links-visitors.tsx@@ -4,11 +4,15 @@ import { TableCell, TableRow } from "@/components/ui/table";import { useLinkVisits } from "@/lib/swr/use-link";import { Gauge } from "@/components/ui/gauge";---export default function LinksVisitors({linkId, linkName}: {linkId: string, linkName: string}) {+export default function LinksVisitors({+ linkId,+ linkName,+}: {+ linkId: string;+ linkName: string;+}) {const { views } = useLinkVisits(linkId);-+return (<>{views@@ -115,4 +119,3 @@ export default function LinksVisitors({linkId, linkName}: {linkId: string, linkN</>);}-diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsxindex 921abfae..0057a128 100644--- a/components/welcome/upload.tsx+++ b/components/welcome/upload.tsx@@ -4,10 +4,6 @@ import { useState } from "react";import { type PutBlobResult } from "@vercel/blob";import { upload } from "@vercel/blob/client";import DocumentUpload from "@/components/document-upload";-import {- ArrowRightIcon,- DocumentDuplicateIcon,-} from "@heroicons/react/24/outline";import { toast } from "sonner";import Skeleton from "../Skeleton";import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";@@ -27,7 +23,6 @@ export default function Upload() {const [currentBlob, setCurrentBlob] = useState<boolean>(false);const [currentLinkId, setCurrentLinkId] = useState<string | null>(null);const [currentDocId, setCurrentDocId] = useState<string | null>(null);- const [copiedLink, setCopiedLink] = useState<boolean>(false);const teamInfo = useTeam();const handleBrowserUpload = async (event: any) => {@@ -82,7 +77,7 @@ export default function Upload() {const saveDocumentToDatabase = async (blob: PutBlobResult,- numPages?: number+ numPages?: number,) => {// create a document in the database with the blob urlconst response = await fetch(@@ -97,7 +92,7 @@ export default function Upload() {url: blob.url,numPages: numPages,}),- }+ },);if (!response.ok) {@@ -116,7 +111,7 @@ export default function Upload() {const handleContinue = (id: string) => {copyToClipboard(`${process.env.NEXT_PUBLIC_BASE_URL}/view/${id}`,- "Link copied to clipboard. Redirecting to document page..."+ "Link copied to clipboard. Redirecting to document page...",);setTimeout(() => {router.push(`/documents/${currentDocId}`);@@ -142,10 +137,12 @@ export default function Upload() {initial="hidden"animate="show"exit="hidden"- transition={{ duration: 0.3, type: "spring" }}>+ transition={{ duration: 0.3, type: "spring" }}+ ><motion.divvariants={STAGGER_CHILD_VARIANTS}- className="flex flex-col items-center space-y-10 text-center">+ className="flex flex-col items-center space-y-10 text-center"+ ><h1 className="font-display text-3xl font-semibold text-foreground transition-colors sm:text-4xl">{`Upload your ${router.query.type}`}</h1>@@ -155,7 +152,8 @@ export default function Upload() {<formencType="multipart/form-data"onSubmit={handleBrowserUpload}- className="flex flex-col">+ className="flex flex-col"+ ><div className="space-y-12"><div className="pb-6"><div className="mt-10 grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">@@ -171,7 +169,8 @@ export default function Upload() {<Buttontype="submit"className="w-full"- disabled={uploading || !currentFile}>+ disabled={uploading || !currentFile}+ >{uploading ? "Uploading..." : "Upload Document"}</Button></div>@@ -197,10 +196,12 @@ export default function Upload() {initial="hidden"animate="show"exit="hidden"- transition={{ duration: 0.3, type: "spring" }}>+ transition={{ duration: 0.3, type: "spring" }}+ ><motion.divvariants={STAGGER_CHILD_VARIANTS}- className="flex flex-col items-center space-y-10 text-center">+ className="flex flex-col items-center space-y-10 text-center"+ ><h1 className="font-display text-3xl font-semibold text-foreground transition-colors sm:text-4xl">Share your unique link</h1>diff --git a/lib/swr/use-link.ts b/lib/swr/use-link.tsindex b7616319..1fb36344 100644--- a/lib/swr/use-link.ts+++ b/lib/swr/use-link.ts@@ -17,7 +17,7 @@ export function useLink() {fetcher,{dedupingInterval: 10000,- }+ },);return {@@ -36,11 +36,15 @@ export function useDomainLink() {};const { data: link, error } = useSWR<LinkWithDocument>(- domain && slug && `/api/links/domains/${encodeURIComponent(domain)}/${encodeURIComponent(slug)}`,+ domain &&+ slug &&+ `/api/links/domains/${encodeURIComponent(domain)}/${encodeURIComponent(+ slug,+ )}`,fetcher,{dedupingInterval: 10000,- }+ },);return {@@ -58,15 +62,13 @@ interface ViewWithDuration extends View {completionRate: number;}-export function useLinkVisits(linkId: string) {-const { data: views, error } = useSWR<ViewWithDuration[]>(linkId && `/api/links/${encodeURIComponent(linkId)}/visits`,fetcher,{dedupingInterval: 10000,- }+ },);return {@@ -74,4 +76,4 @@ export function useLinkVisits(linkId: string) {loading: !error && !views,error,};-}\ No newline at end of file+}diff --git a/pages/api/links/[id]/visits.ts b/pages/api/links/[id]/visits.tsindex 5e98d991..8ecbe303 100644--- a/pages/api/links/[id]/visits.ts+++ b/pages/api/links/[id]/visits.ts@@ -10,7 +10,7 @@ import { errorhandler } from "@/lib/errorHandler";export default async function handle(req: NextApiRequest,- res: NextApiResponse+ res: NextApiResponse,) {if (req.method === "GET") {// GET /api/links/:id/visits@@ -91,7 +91,7 @@ export default async function handle(const summedDurations = durations.map((duration) => {return duration.data.reduce((totalDuration, data) => totalDuration + data.sum_duration,- 0+ 0,);});@@ -112,7 +112,7 @@ export default async function handle(// TODO: Check that the user is owner of the links, otherwise return 401- // console.log("viewsWithDuration:", viewsWithDuration)+ // console.log("viewsWithDuration:", viewsWithDuration);return res.status(200).json(viewsWithDuration);} catch (error) {diff --git a/pages/api/record_view.ts b/pages/api/record_view.tsindex 9951d9b3..5c3d37c0 100644--- a/pages/api/record_view.ts+++ b/pages/api/record_view.ts@@ -8,7 +8,6 @@ import { LOCALHOST_GEO_DATA, getGeoData } from "@/lib/utils/geo";import { z } from "zod";-const bodyValidation = z.object({id: z.string(),linkId: z.string(),@@ -41,7 +40,7 @@ const bodyValidation = z.object({export default async function handle(req: NextApiRequest,- res: NextApiResponse+ res: NextApiResponse,) {// We only allow POST requestsif (req.method !== "POST") {@@ -52,11 +51,18 @@ export default async function handle(const geo: Geo =process.env.VERCEL === "1" ? getGeoData(req.headers) : LOCALHOST_GEO_DATA;-const referer = req.headers.referer;const ua = userAgentFromString(req.headers["user-agent"]);- const { linkId, documentId, viewId, duration, pageNumber, versionNumber } = req.body as { linkId: string, documentId: string, viewId: string, duration: number, pageNumber: number, versionNumber: number };+ const { linkId, documentId, viewId, duration, pageNumber, versionNumber } =+ req.body as {+ linkId: string;+ documentId: string;+ viewId: string;+ duration: number;+ pageNumber: number;+ versionNumber: number;+ };const time = Date.now(); // in milliseconds@@ -94,14 +100,16 @@ export default async function handle(const result = bodyValidation.safeParse(pageViewObject);if (!result.success) {- return res.status(400).json(- { error: `Invalid body: ${result.error.message}` }- );+ return res+ .status(400)+ .json({ error: `Invalid body: ${result.error.message}` });}try {await publishPageView(result.data);+ // console.log(`Recorded view for ${linkId}`, result.data);+res.status(200).json({ message: "View recorded" });} catch (error) {log(`Failed to record view for ${linkId}. Error: \n\n ${error}`);