Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
update links table with domain
Marc Seitz1cc11c806046
diff --git a/components/links/links-table.tsx b/components/links/links-table.tsxindex 3d85b88a..8b482c2d 100644--- a/components/links/links-table.tsx+++ b/components/links/links-table.tsx@@ -23,7 +23,7 @@ import { Button } from "@/components/ui/button";import { useDocumentLinks } from "@/lib/swr/use-document";import BarChart from "../shared/icons/bar-chart";-import { copyToClipboard, nFormatter, timeAgo } from "@/lib/utils";+import { cn, copyToClipboard, nFormatter, timeAgo } from "@/lib/utils";import MoreHorizontal from "../shared/icons/more-horizontal";import { Skeleton } from "../ui/skeleton";import LinksVisitors from "./links-visitors";@@ -36,9 +36,13 @@ import { useState } from "react";import { LinkWithViews } from "@/lib/types";import { mutate } from "swr";import { toast } from "sonner";+import { useRouter } from "next/router";+import { usePlan } from "@/lib/swr/use-billing";export default function LinksTable() {const { links } = useDocumentLinks();+ const router = useRouter();+ const { plan } = usePlan()const [isLoading, setIsLoading] = useState<boolean>(false);const [isLinkSheetVisible, setIsLinkSheetVisible] = useState<boolean>(false);@@ -108,6 +112,8 @@ export default function LinksTable() {? links.filter((link) => link.isArchived).length: 0;+ const hasFreePlan = plan && plan.plan === "free"+return (<><div className="w-full sm:p-4">@@ -136,36 +142,63 @@ export default function LinksTable() {<><TableRow key={link.id} className="group/row"><TableCell className="hidden sm:table-cell font-medium truncate w-[220px]">- {link.name || "No link name"}+ {link.name || "No link name"}{" "}+ {link.domainId && hasFreePlan ? (+ <span className="text-foreground bg-destructive ring-1 ring-destructive rounded-full px-2.5 py-0.5 text-xs ml-2">+ Inactive+ </span>+ ) : null}</TableCell><TableCell className="max-w-[150px] sm:min-w-[450px]">- <div className="group/cell flex items-center gap-x-4 rounded-md text-secondary-foreground bg-secondary px-3 py-1 group-hover/row:ring-1 group-hover/row:ring-gray-400 hover:bg-emerald-700 hover:dark:bg-emerald-200 group-hover/row:dark:ring-gray-100 transition-all">+ <div+ className={cn(+ `group/cell flex items-center gap-x-4 rounded-md text-secondary-foreground px-3 py-1 group-hover/row:ring-1 group-hover/row:ring-gray-400 group-hover/row:dark:ring-gray-100 transition-all`,+ link.domainId && hasFreePlan+ ? "bg-destructive hover:bg-red-700 hover:dark:bg-red-200"+ : "bg-secondary hover:bg-emerald-700 hover:dark:bg-emerald-200"+ )}+ ><div className="whitespace-nowrap hidden sm:flex text-sm group-hover/cell:hidden">{link.domainId? `https://${link.domainSlug}/${link.slug}`: `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`}</div><div className="flex sm:hidden whitespace-nowrap text-sm group-hover/cell:hidden truncate">{`${link.id}`}</div>- <button- className="whitespace-nowrap text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block w-full"- onClick={- link.domainId- ? () =>- handleCopyToClipboard(- `https://${link.domainSlug}/${link.slug}`- )- : () =>- handleCopyToClipboard(- `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`- )- }- title="Copy to clipboard"- >- Copy{" "}- <span className="hidden sm:inline-flex">- to Clipboard- </span>- </button>+ {link.domainId && hasFreePlan ? (+ <button+ className="whitespace-nowrap text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block w-full"+ onClick={() =>+ router.push("/settings/billing")+ }+ title="Upgrade to activate link"+ >+ Upgrade{" "}+ <span className="hidden sm:inline-flex">+ to activate link+ </span>+ </button>+ ) : (+ <button+ className="whitespace-nowrap text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block w-full"+ onClick={+ link.domainId+ ? () =>+ handleCopyToClipboard(+ `https://${link.domainSlug}/${link.slug}`+ )+ : () =>+ handleCopyToClipboard(+ `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`+ )+ }+ title="Copy to clipboard"+ >+ Copy{" "}+ <span className="hidden sm:inline-flex">+ to Clipboard+ </span>+ </button>+ )}</div></TableCell><TableCell>