Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
enhance: polished the document dashboard page
ashrafchowdury5f90d69da1a3
diff --git a/components/documents/process-status-bar.tsx b/components/documents/process-status-bar.tsxindex 608978e9..0725d373 100644--- a/components/documents/process-status-bar.tsx+++ b/components/documents/process-status-bar.tsx@@ -2,11 +2,14 @@ import { Progress } from "@/components/ui/progress";import ErrorPage from "next/error";import { useDocumentProcessingStatus } from "@/lib/swr/use-document";import { useEffect, useState } from "react";+import { cn } from "@/lib/utils";export default function ProcessStatusBar({documentVersionId,+ className,}: {documentVersionId: string;+ className?: string;}) {const { status, loading, error } =useDocumentProcessingStatus(documentVersionId);@@ -33,8 +36,19 @@ export default function ProcessStatusBar({}if (loading) {- return <Progress value={0} />;+ return (+ <Progress value={0} className={cn("w-full rounded-none", className)} />+ );}- return <Progress value={progress} text={text} className="w-[60%]" />;+ return (+ <Progress+ value={progress}+ text={text}+ className={cn(+ "w-full text-[8px] font-semibold capitalize rounded-none",+ className,+ )}+ />+ );}diff --git a/components/documents/stats-card.tsx b/components/documents/stats-card.tsxindex 06232578..34be7324 100644--- a/components/documents/stats-card.tsx+++ b/components/documents/stats-card.tsx@@ -1,7 +1,8 @@import { useStats } from "@/lib/swr/use-stats";import ErrorPage from "next/error";import StatsElement from "./stats-element";-import StatsElementPlaceholder from "./stats-element-placeholder";+import StatsCardSkeleton from "../skeletons/stats-card-skeleton";+import { BarChart3, ThumbsUp, TimerIcon } from "lucide-react";export default function StatsCard() {const { stats, loading, error } = useStats();@@ -12,9 +13,9 @@ export default function StatsCard() {if (loading) {return (- <div className="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3 border-b border-foreground/5">+ <div className="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3 border-foreground/5 space-y-2 sm:space-y-0 sm:space-x-2 lg:space-x-3">{Array.from({ length: 3 }).map((_, i) => (- <StatsElementPlaceholder key={i} statIdx={i} />+ <StatsCardSkeleton key={i} />))}</div>);@@ -30,16 +31,19 @@ export default function StatsCard() {const statistics = [{name: "Number of visits",+ icon: BarChart3,value: stats?.views.length.toString() ?? "0",active: true,},{name: "Number of reactions",+ icon: ThumbsUp,value: groupedReactionsTotal,active: true,},{name: "Total average view duration",+ icon: TimerIcon,value:stats?.total_duration == null? "46"@@ -56,7 +60,7 @@ export default function StatsCard() {];return stats && stats.views.length > 0 ? (- <div className="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3 border-b border-foreground/5">+ <div className="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3 border-foreground/5 space-y-2 sm:space-y-0 sm:space-x-2 lg:space-x-3">{statistics.map((stat, statIdx) => (<StatsElement key={statIdx} stat={stat} statIdx={statIdx} />))}diff --git a/components/documents/stats-chart.tsx b/components/documents/stats-chart.tsxindex 989337e6..9cef2a09 100644--- a/components/documents/stats-chart.tsx+++ b/components/documents/stats-chart.tsx@@ -1,6 +1,7 @@import { useStats } from "@/lib/swr/use-stats";import ErrorPage from "next/error";import BarChartComponent from "../charts/bar-chart";+import StatsChartSkeleton from "../skeletons/stats-chart-skeleton";export default function StatsChart({documentId,@@ -16,7 +17,7 @@ export default function StatsChart({}if (loading) {- return <div>No data</div>;+ return <StatsChartSkeleton className="my-8" />;}let durationData = Array.from({ length: totalPagesMax }, (_, i) => ({@@ -76,7 +77,7 @@ export default function StatsChart({}return stats && stats.views.length > 0 ? (- <div className="p-5">+ <div className="pl-0.5 md:pl-1 pb-0.5 md:pb-1 border-l border-b rounded-bl-lg"><BarChartComponent data={durationData} /></div>) : null;diff --git a/components/documents/stats-element-placeholder.tsx b/components/documents/stats-element-placeholder.tsxdeleted file mode 100644index 4e506fdf..00000000--- a/components/documents/stats-element-placeholder.tsx+++ /dev/null@@ -1,21 +0,0 @@-import { classNames } from "@/lib/utils";--export default function StatsElementPlaceholder({- statIdx,-}: {- statIdx: number;-}) {- return (- <div- className={classNames(- statIdx % 2 === 1 ? "sm:border-l" : statIdx === 2 ? "lg:border-l" : "",- "border-t border-foreground/5 py-6 px-4 sm:px-6 lg:px-8",- )}- >- <div className="h-4 w-full animate-pulse rounded-md bg-gray-200 dark:bg-gray-800" />- <div className="mt-4 flex gap-x-2">- <div className="h-8 w-8 animate-pulse rounded-md bg-gray-200 dark:bg-gray-800" />- </div>- </div>- );-}diff --git a/components/documents/stats-element.tsx b/components/documents/stats-element.tsxindex b1cb3462..660dc295 100644--- a/components/documents/stats-element.tsx+++ b/components/documents/stats-element.tsx@@ -1,7 +1,9 @@-import { classNames } from "@/lib/utils";+import { cn } from "@/lib/utils";+import { LucideType } from "lucide-react";interface Stat {name: string;+ icon: typeof LucideType;value: string;unit?: string;active: boolean;@@ -15,24 +17,27 @@ export default function StatsElement({ stat, statIdx }: StatsElementProps) {return (<divkey={statIdx}- className={classNames(- statIdx % 2 === 1 ? "sm:border-l" : statIdx === 2 ? "lg:border-l" : "",- "border-t border-foreground/5 py-6 px-4 sm:px-6 lg:px-8",- )}+ className="border border-foreground/5 py-6 px-6 xl:px-8 rounded-lg overflow-hidden">- <p- className={classNames(+ <div+ className={cn(+ "flex sm:flex-col lg:flex-row items-center sm:items-start lg:items-center space-x-2 sm:space-x-0 sm:space-y-2 lg:space-y-0 lg:space-x-2",!stat.active? "text-gray-300 dark:text-gray-700": "text-muted-foreground",- "text-sm font-medium leading-6",)}>- {stat.name}- </p>- <p className="mt-2 flex items-baseline gap-x-2">+ <div className="*:w-5 sm:*:w-6 lg:*:w-5 *:h-5 sm:*:h-6 lg:*:h-5">+ <stat.icon />+ </div>+ <p className="text-sm font-medium leading-6 whitespace-nowrap capitalize">+ {stat.name}+ </p>+ </div>++ <p className="mt-3 flex items-baseline gap-x-2"><span- className={classNames(+ className={cn(!stat.active? "text-gray-300 dark:text-gray-700": "text-foreground",@@ -43,7 +48,7 @@ export default function StatsElement({ stat, statIdx }: StatsElementProps) {</span>{stat.unit ? (<span- className={classNames(+ className={cn(!stat.active? "text-gray-300 dark:text-gray-700": "text-muted-foreground",diff --git a/components/links/link-sheet/domain-section.tsx b/components/links/link-sheet/domain-section.tsxindex 38262814..4db7233a 100644--- a/components/links/link-sheet/domain-section.tsx+++ b/components/links/link-sheet/domain-section.tsx@@ -7,6 +7,15 @@ import { AddDomainModal } from "@/components/domains/add-domain-modal";import { mutate } from "swr";import Link from "next/link";import { useTeam } from "@/context/team-context";+import {+ Select,+ SelectGroup,+ SelectValue,+ SelectTrigger,+ SelectContent,+ SelectItem,+} from "@/components/ui/select";+import { Input } from "@/components/ui/input";export default function DomainSection({data,@@ -20,9 +29,7 @@ export default function DomainSection({const [isModalOpen, setModalOpen] = useState(false);const teamInfo = useTeam();- const handleDomainChange = (event: React.ChangeEvent<HTMLSelectElement>) => {- const value = event.target.value;-+ const handleDomainChange = (value: string) => {if (value === "add_domain") {// Redirect to the add domain pagesetModalOpen(true);@@ -32,9 +39,11 @@ export default function DomainSection({setData({ ...data, domain: value });};- const handleSelectFocus = () => {- // Assuming your fetcher key for domains is '/api/teams/:teamId/domains'- mutate(`/api/teams/${teamInfo?.currentTeam?.id}/domains`);+ const handleSelectFocus = (open: boolean) => {+ if (open) {+ // Assuming your fetcher key for domains is '/api/teams/:teamId/domains'+ mutate(`/api/teams/${teamInfo?.currentTeam?.id}/domains`);+ }};const currentDomain = domains?.find((domain) => domain.slug === data.domain);@@ -43,33 +52,32 @@ export default function DomainSection({return (<><Label htmlFor="link-domain">Domain</Label>- <div className="flex">- <select+ <div className="px-1">+ <Selectvalue={data.domain || "papermark.io"}- onChange={handleDomainChange}- onFocus={handleSelectFocus}- className={cn(- "w-48 rounded-l-md border border-r-0 border-border bg-secondary px-5 text-sm text-secondary-foreground focus:border-border focus:outline-none focus:ring-0",- data.domain && data.domain !== "papermark.io"- ? ""- : "rounded-r-md border-r-1",- )}+ onValueChange={handleDomainChange}+ onOpenChange={handleSelectFocus}>- <option key="papermark.io" value="papermark.io">- papermark.io- </option>- {domains- // ?.filter((domain) => domain.verified)- ?.map(({ slug }) => (- <option key={slug} value={slug}>- {slug}- </option>- ))}- <option value="add_domain">Add a custom domain ✨</option>- </select>+ <SelectTrigger>+ <SelectValue placeholder="papermark.io" />+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ <SelectItem key="papermark.io" value="papermark.io">+ papermark.io+ </SelectItem>+ {domains?.map(({ slug }) => (+ <SelectItem key={slug} value={slug}>+ {slug}+ </SelectItem>+ ))}+ <SelectItem value="add_domain">Add a custom domain ✨</SelectItem>+ </SelectGroup>+ </SelectContent>+ </Select>{data.domain && data.domain !== "papermark.io" ? (- <input+ <Inputtype="text"name="key"required@@ -82,10 +90,10 @@ export default function DomainSection({}}autoComplete="off"className={cn(- "hidden w-full rounded-r-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",+ "hidden w-full mt-5 placeholder:text-muted-foreground",data.domain && data.domain !== "papermark.io" ? "flex" : "",)}- placeholder="deck"+ placeholder="Deck"onChange={(e) => {e.currentTarget.setCustomValidity("");setData({ ...data, slug: e.target.value });@@ -93,20 +101,20 @@ export default function DomainSection({aria-invalid="true"/>) : null}- </div>- {data.domain && data.domain !== "papermark.io" && !isDomainVerified ? (- <div className="text-sm text-red-500 mt-4">- Your domain is not verified yet!{" "}- <Link- className="underline hover:text-red-500/80"- href="/settings/domains"- target="_blank"- >- Verify now- </Link>- </div>- ) : null}+ {data.domain && data.domain !== "papermark.io" && !isDomainVerified ? (+ <div className="text-sm text-red-500 mt-3">+ Your domain is not verified yet!{" "}+ <Link+ className="underline hover:text-red-500/80"+ href="/settings/domains"+ target="_blank"+ >+ Verify now+ </Link>+ </div>+ ) : null}+ </div><AddDomainModal open={isModalOpen} setOpen={setModalOpen} /></>diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsxindex 91d76620..63cee112 100644--- a/components/links/link-sheet/index.tsx+++ b/components/links/link-sheet/index.tsx@@ -167,8 +167,8 @@ export default function LinkSheet({return (<Sheet open={isOpen} onOpenChange={(open: boolean) => setIsOpen(open)}>- <SheetContent className="bg-background text-foreground flex flex-col justify-between">- <SheetHeader>+ <SheetContent className="bg-background text-foreground flex flex-col justify-between px-4 md:px-5 w-[90%] sm:w-[450px]">+ <SheetHeader className="text-start"><SheetTitle>{currentLink ? "Edit link" : "Create a new link"}</SheetTitle>diff --git a/components/links/links-table.tsx b/components/links/links-table.tsxindex c870cb68..f1ca88cc 100644--- a/components/links/links-table.tsx+++ b/components/links/links-table.tsx@@ -25,7 +25,6 @@ import { useDocumentLinks } from "@/lib/swr/use-document";import BarChart from "../shared/icons/bar-chart";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";import ChevronDown from "../shared/icons/chevron-down";import LinkSheet, {@@ -39,8 +38,15 @@ import { toast } from "sonner";import { useRouter } from "next/router";import { usePlan } from "@/lib/swr/use-billing";import { useTeam } from "@/context/team-context";+import { Archive, FilePen } from "lucide-react";+import LinksTableSekeleton from "../skeletons/links-table-sekeleton";+import ProcessStatusBar from "../documents/process-status-bar";-export default function LinksTable() {+export default function LinksTable({+ primaryVersion,+}: {+ primaryVersion: any;+}) {const { links } = useDocumentLinks();const router = useRouter();const { plan } = usePlan();@@ -131,21 +137,21 @@ export default function LinksTable() {return (<>- <div className="w-full sm:p-4">+ <div className="w-full"><div>- <h2 className="p-4">All links</h2>+ <h2 className="mb-2 md:mb-4">All links</h2></div>- <div className="rounded-md sm:border">+ <div className="rounded-md border"><Table><TableHeader>- <TableRow className="hover:bg-transparent">- <TableHead className="font-medium hidden sm:table-cell">- Name+ <TableRow className="hover:bg-transparent *:whitespace-nowrap *:font-medium">+ <TableHead>Name</TableHead>+ <TableHead className="w-[150px] sm:w-[200px] md:w-[250px]">+ Link</TableHead>- <TableHead className="font-medium sm:w-[250px]">Link</TableHead>- <TableHead className="font-medium">Views</TableHead>- <TableHead className="font-medium">Last Viewed</TableHead>- <TableHead className="font-medium text-center sm:text-right"></TableHead>+ <TableHead className="w-[250px] sm:w-auto">Views</TableHead>+ <TableHead>Last Viewed</TableHead>+ <TableHead className="ftext-center sm:text-right"></TableHead></TableRow></TableHeader><TableBody>@@ -156,7 +162,7 @@ export default function LinksTable() {<Collapsible key={link.id} asChild><><TableRow key={link.id} className="group/row">- <TableCell className="hidden sm:table-cell font-medium truncate w-[220px]">+ <TableCell className="font-medium truncate w-[220px]">{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">@@ -164,60 +170,63 @@ export default function LinksTable() {</span>) : null}</TableCell>- <TableCell className="max-w-[150px] sm:min-w-[450px]">+ <TableCell className="max-w-[250px] sm:min-w-[300px] md:min-w-[400px] lg:min-w-[450px]"><divclassName={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`,+ `group/cell relative w-full overflow-hidden flex items-center gap-x-4 rounded-sm text-secondary-foreground text-center px-3 py-1.5 md:py-1 group-hover/row:ring-1 group-hover/row:ring-gray-400 group-hover/row:dark:ring-gray-100 transition-all truncate`,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">+ {/* Progress bar */}+ {primaryVersion.type !== "notion" &&+ !primaryVersion.hasPages ? (+ <ProcessStatusBar+ documentVersionId={primaryVersion.id}+ className="absolute z-20 top-0 left-0 right-0 bottom-0 h-full gap-x-8 flex items-center"+ />+ ) : null}++ <div className="whitespace-nowrap w-full flex text-xs md:text-sm group-hover/cell:opacity-0">{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>+{link.domainId && hasFreePlan ? (<button- className="whitespace-nowrap text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block w-full"+ className="whitespace-nowrap text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block w-full absolute top-0 left-0 right-0 bottom-0 z-10"onClick={() =>router.push("/settings/billing")}title="Upgrade to activate link">- Upgrade{" "}- <span className="hidden sm:inline-flex">- to activate link- </span>+ Upgrade to activate link</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}`,- )+ className="whitespace-nowrap w-full text-xs sm:text-sm text-center group-hover/cell:text-primary-foreground hidden group-hover/cell:block absolute top-0 left-0 right-0 bottom-0 z-10"+ onClick={() =>+ handleCopyToClipboard(+ link.domainId+ ? `https://${link.domainSlug}/${link.slug}`+ : `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`,+ )}title="Copy to clipboard">- Copy{" "}- <span className="hidden sm:inline-flex">- to Clipboard- </span>+ Copy to Clipboard</button>)}</div></TableCell><TableCell>- <CollapsibleTrigger asChild>+ <CollapsibleTrigger+ disabled={+ Number(nFormatter(link._count.views)) === 0+ }+ ><div className="flex items-center space-x-1 [&[data-state=open]>svg.chevron]:rotate-180"><BarChart className="h-4 w-4 text-muted-foreground" /><p className="whitespace-nowrap text-sm text-muted-foreground">@@ -253,12 +262,12 @@ export default function LinksTable() {</DropdownMenuTrigger><DropdownMenuContent align="end"><DropdownMenuLabel>Actions</DropdownMenuLabel>+ <DropdownMenuSeparator /><DropdownMenuItemonClick={() => handleEditLink(link)}>- Edit Link+ <FilePen className="w-4 h-4 mr-2" /> Edit Link</DropdownMenuItem>- <DropdownMenuSeparator /><DropdownMenuItemclassName="text-destructive focus:bg-destructive focus:text-destructive-foreground"onClick={() =>@@ -269,7 +278,7 @@ export default function LinksTable() {)}>- Archive+ <Archive className="w-4 h-4 mr-2" /> Archive</DropdownMenuItem></DropdownMenuContent></DropdownMenu>@@ -285,30 +294,19 @@ export default function LinksTable() {</Collapsible>))) : (- <TableRow>- <TableCell className="min-w-[100px]">- <Skeleton className="h-6 w-full" />- </TableCell>- <TableCell className="min-w-[450px]">- <Skeleton className="h-6 w-full" />- </TableCell>- <TableCell>- <Skeleton className="h-6 w-24" />- </TableCell>- <TableCell>- <Skeleton className="h-6 w-24" />- </TableCell>- </TableRow>+ <LinksTableSekeleton />)}</TableBody></Table></div>+<LinkSheetisOpen={isLinkSheetVisible}setIsOpen={setIsLinkSheetVisible}currentLink={selectedLink}/>- {archivedLinksCount > 0 ? (++ {archivedLinksCount > 0 && (<Collapsible asChild><><CollapsibleTrigger asChild>@@ -321,116 +319,109 @@ export default function LinksTable() {<ChevronDown className="h-4 w-4 text-gray-400 transition-transform duration-200 chevron" /></Button></CollapsibleTrigger>- <CollapsibleContent>+ <CollapsibleContent className="mt-2"><div>- <h2 className="p-4">Archived Links</h2>+ <h2 className="mb-2 md:mb-4">Archived Links</h2></div>- <div className="rounded-md sm:border">+ <div className="rounded-md border"><Table><TableHeader>- <TableRow className="hover:bg-transparent">- <TableHead className="font-medium hidden sm:table-cell">- Name- </TableHead>- <TableHead className="font-medium sm:w-[250px]">+ <TableRow className="hover:bg-transparent *:whitespace-nowrap *:font-medium">+ <TableHead>Name</TableHead>+ <TableHead className="w-[150px] sm:w-[200px] md:w-[250px]">Link</TableHead>- <TableHead className="font-medium">Views</TableHead>- <TableHead className="font-medium">- Last Viewed- </TableHead>- <TableHead className="font-medium text-center sm:text-right"></TableHead>+ <TableHead>Views</TableHead>+ <TableHead>Last Viewed</TableHead>+ <TableHead className="ftext-center sm:text-right"></TableHead></TableRow></TableHeader><TableBody>- {links- ? links- .filter((link) => link.isArchived)- .map((link) => (- <>- <TableRow key={link.id} className="group/row">- <TableCell className="hidden sm:table-cell truncate w-[220px]">- {link.name || "No link name"}- </TableCell>- <TableCell className="max-w-[150px] sm:min-w-[450px]">- <div className="flex items-center gap-x-4 rounded-md text-secondary-foreground bg-secondary group-hover/row:ring-1 group-hover/row:ring-gray-400 group-hover/row:dark:ring-gray-100 px-3 py-1">- <div className="whitespace-nowrap hidden sm:flex text-sm">- {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 truncate">{`${link.id}`}</div>- </div>- </TableCell>- <TableCell>- <div className="flex items-center space-x-1 [&[data-state=open]>svg.chevron]:rotate-180">- <BarChart className="h-4 w-4 text-gray-400" />- <p className="whitespace-nowrap text-sm text-gray-400">- {nFormatter(link._count.views)}- <span className="ml-1 hidden sm:inline-block">- views- </span>- </p>- </div>- </TableCell>- <TableCell className="text-sm text-gray-400">- {link.views[0] ? (- <time- dateTime={new Date(- link.views[0].viewedAt,- ).toISOString()}+ {links &&+ links+ .filter((link) => link.isArchived)+ .map((link) => (+ <>+ <TableRow key={link.id} className="group/row">+ <TableCell className="truncate w-[180px]">+ {link.name || "No link name"}+ </TableCell>+ <TableCell className="max-w-[250px] sm:min-w-[300px] md:min-w-[400px] lg:min-w-[450px]">+ <div className="flex items-center gap-x-4 whitespace-nowrap text-xs sm:text-sm rounded-sm text-secondary-foreground bg-secondary px-3 py-1.5 sm:py-1">+ {link.domainId+ ? `https://${link.domainSlug}/${link.slug}`+ : `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`}+ </div>+ </TableCell>+ <TableCell>+ <div className="flex items-center space-x-1 [&[data-state=open]>svg.chevron]:rotate-180">+ <BarChart className="h-4 w-4 text-gray-400" />+ <p className="whitespace-nowrap text-sm text-gray-400">+ {nFormatter(link._count.views)}+ <span className="ml-1 hidden sm:inline-block">+ views+ </span>+ </p>+ </div>+ </TableCell>+ <TableCell className="text-sm text-gray-400">+ {link.views[0] ? (+ <time+ dateTime={new Date(+ link.views[0].viewedAt,+ ).toISOString()}+ >+ {timeAgo(link.views[0].viewedAt)}+ </time>+ ) : (+ "-"+ )}+ </TableCell>+ <TableCell className="text-center sm:text-right">+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ className="h-8 w-8 p-0">- {timeAgo(link.views[0].viewedAt)}- </time>- ) : (- "-"- )}- </TableCell>- <TableCell className="text-center sm:text-right">- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="ghost"- className="h-8 w-8 p-0"- >- <span className="sr-only">- Open menu- </span>- <MoreHorizontal className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuLabel>- Actions- </DropdownMenuLabel>+ <span className="sr-only">+ Open menu+ </span>+ <MoreHorizontal className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuLabel>+ Actions+ </DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuItem- className="text-destructive focus:bg-destructive focus:text-destructive-foreground"- onClick={() =>- handleArchiveLink(- link.id,- link.documentId,- link.isArchived,- )- }- >- Reactivate- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </TableCell>- </TableRow>- </>- ))- : null}+ <DropdownMenuSeparator />+ <DropdownMenuItem+ className="text-destructive focus:bg-destructive focus:text-destructive-foreground"+ onClick={() =>+ handleArchiveLink(+ link.id,+ link.documentId,+ link.isArchived,+ )+ }+ >+ <Archive className="w-4 h-4 mr-2" />+ Reactivate+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </TableCell>+ </TableRow>+ </>+ ))}</TableBody></Table></div></CollapsibleContent></></Collapsible>- ) : null}+ )}</div></>);diff --git a/components/links/links-visitors.tsx b/components/links/links-visitors.tsxindex ce41efe4..aca45277 100644--- a/components/links/links-visitors.tsx+++ b/components/links/links-visitors.tsx@@ -3,6 +3,7 @@ import { TableCell, TableRow } from "@/components/ui/table";import { useLinkVisits } from "@/lib/swr/use-link";import { Gauge } from "@/components/ui/gauge";import { VisitorAvatar } from "@/components/visitors/visitor-avatar";+import LinksVisitorsSkeleton from "../skeletons/links-visitors-skeleton";export default function LinksVisitors({linkId,@@ -15,99 +16,54 @@ export default function LinksVisitors({return (<>- {views- ? views.map((view) => (- <TableRow key={view.id}>- {/* TableCell for large screens */}- <TableCell colSpan={3} className="hidden sm:table-cell">- <div>- <div className="flex items-center justify-between">- <div className="flex items-center space-x-3 overflow-visible w-[220px]">- <VisitorAvatar viewerEmail={view.viewerEmail} />- <div className="min-w-0 flex-1">- <div className="focus:outline-none">- <p className="text-sm text-gray-800 dark:text-gray-200 overflow-visible">- {view.viewerEmail ? view.viewerEmail : "Anonymous"}- </p>- {/* <p className="text-sm text-gray-500">- <span>{linkName}</span>- </p> */}- </div>- </div>- </div>- <div className="flex space-x-4 items-center">- <div className="text-sm text-muted-foreground">- {durationFormat(view.totalDuration)}- </div>+ {views ? (+ views.map((view) => (+ <TableRow key={view.id}>+ <TableCell colSpan={2}>+ <div className="flex items-center sm:space-x-3 overflow-visible">+ <VisitorAvatar+ viewerEmail={view.viewerEmail}+ className="w-7 md:w-8 h-7 md:h-8 text-xs md:text-sm"+ />- <div className="text-sm">- <Gauge- value={view.completionRate}- size={"small"}- showValue={true}- />- </div>- </div>- </div>- </div>- </TableCell>- {/* TableCell for small screens */}- <TableCell colSpan={4} className="table-cell sm:hidden">- <div>- <div className="flex items-center justify-between">- <div className="flex items-center truncate w-[220px]">- <VisitorAvatar viewerEmail={view.viewerEmail} />- <div className="min-w-0 flex-1">- <div className="focus:outline-none">- <p className="text-sm font-medium text-muted-foreground overflow-visible">- {view.viewerEmail}- </p>- <p className="text-sm text-muted-foreground">- <span>{linkName}</span>- <span className="inline-flex">- • - <time- className="truncate text-sm text-muted-foreground"- dateTime={new Date(view.viewedAt).toISOString()}- >- {timeAgo(view.viewedAt)}- </time>- </span>- </p>- </div>- </div>- </div>- <div className="flex space-x-4 items-center">- <div className="text-sm text-muted-foreground">- {durationFormat(view.totalDuration)}- </div>+ <p className="text-sm text-gray-800 dark:text-gray-200 overflow-visible">+ {view.viewerEmail ? view.viewerEmail : "Anonymous"}+ </p>+ </div>+ </TableCell>- <div className="text-sm">- <Gauge- value={view.completionRate}- size={"small"}- showValue={true}- />- </div>- </div>- </div>+ <TableCell>+ <div className="flex space-x-2 md:space-x-4 items-center">+ <div className="text-sm text-muted-foreground whitespace-nowrap">+ {durationFormat(view.totalDuration)}</div>- </TableCell>- {/* TableCell date only on large screens */}- <TableCell className="hidden sm:table-cell">- <div>- <time- className="truncate text-sm text-muted-foreground"- dateTime={new Date(view.viewedAt).toISOString()}- >- {timeAgo(view.viewedAt)}- </time>++ <div className="text-xs md:text-sm">+ <Gauge+ value={view.completionRate}+ size={"small"}+ showValue={true}+ /></div>- </TableCell>- <TableCell className="hidden sm:table-cell"></TableCell>- </TableRow>- ))- : null}+ </div>+ </TableCell>++ <TableCell>+ <div>+ <time+ className="truncate text-sm text-muted-foreground"+ dateTime={new Date(view.viewedAt).toISOString()}+ >+ {timeAgo(view.viewedAt)}+ </time>+ </div>+ </TableCell>+ <TableCell className="hidden sm:table-cell"></TableCell>+ </TableRow>+ ))+ ) : (+ <LinksVisitorsSkeleton />+ )}</>);}diff --git a/components/skeletons/links-table-sekeleton.tsx b/components/skeletons/links-table-sekeleton.tsxnew file mode 100644index 00000000..caa317a6--- /dev/null+++ b/components/skeletons/links-table-sekeleton.tsx@@ -0,0 +1,23 @@+import { TableCell, TableRow } from "@/components/ui/table";+import { Skeleton } from "../ui/skeleton";++const LinksTableSekeleton = () => {+ return (+ <TableRow>+ <TableCell className="min-w-[100px]">+ <Skeleton className="h-6 w-full" />+ </TableCell>+ <TableCell className="min-w-[450px]">+ <Skeleton className="h-6 w-full" />+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-24" />+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-24" />+ </TableCell>+ </TableRow>+ );+};++export default LinksTableSekeleton;diff --git a/components/skeletons/links-visitors-skeleton.tsx b/components/skeletons/links-visitors-skeleton.tsxnew file mode 100644index 00000000..9132b0ed--- /dev/null+++ b/components/skeletons/links-visitors-skeleton.tsx@@ -0,0 +1,23 @@+import { TableCell, TableRow } from "@/components/ui/table";+import { Skeleton } from "../ui/skeleton";++const LinksVisitorsSkeleton = () => {+ return (+ <TableRow>+ <TableCell colSpan={2}>+ <div className="flex items-center space-x-2">+ <Skeleton className="h-10 w-10 rounded-full" />+ <Skeleton className="h-6 w-[220px]" />+ </div>+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-24" />+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-16" />+ </TableCell>+ </TableRow>+ );+};++export default LinksVisitorsSkeleton;diff --git a/components/skeletons/stats-card-skeleton.tsx b/components/skeletons/stats-card-skeleton.tsxnew file mode 100644index 00000000..e4568352--- /dev/null+++ b/components/skeletons/stats-card-skeleton.tsx@@ -0,0 +1,10 @@+import { Skeleton } from "../ui/skeleton";++export default function StatsCardSkeleton() {+ return (+ <div className="border border-foreground/5 py-6 px-4 sm:px-6 lg:px-8 rounded-lg">+ <Skeleton className="h-6 w-[80%] rounded-sm" />+ <Skeleton className="mt-4 h-8 w-9" />+ </div>+ );+}diff --git a/components/skeletons/stats-chart-skeleton.tsx b/components/skeletons/stats-chart-skeleton.tsxnew file mode 100644index 00000000..84883c93--- /dev/null+++ b/components/skeletons/stats-chart-skeleton.tsx@@ -0,0 +1,31 @@+import { Skeleton } from "../ui/skeleton";+import { cn } from "@/lib/utils";++const StatsChartSkeleton = ({ className }: { className?: string }) => {+ return (+ <section+ className={cn("px-4 border-l border-b rounded-bl-lg", className)}+ >+ <div className="flex items-center justify-end">+ <Skeleton className="h-4 w-28" />+ </div>+ <div className="flex justify-start items-end space-x-8">+ <div className="flex flex-col">+ {Array.from({ length: 5 }).map((_, i) => (+ <Skeleton className="w-10 h-4 rounded-sm my-[18px]" />+ ))}+ </div>+ <div className="w-full flex items-end space-x-4 sm:space-x-5 md:space-x-8">+ {[250, 200, 150, 100, 50, 20].map((item, i) => (+ <Skeleton+ className="w-16 sm:w-20 md:w-28 !rounded-t-lg rounded-b-none"+ style={{ height: `${item}px` }}+ />+ ))}+ </div>+ </div>+ </section>+ );+};++export default StatsChartSkeleton\ No newline at end of filediff --git a/components/skeletons/visitors-table-skeleton.tsx b/components/skeletons/visitors-table-skeleton.tsxnew file mode 100644index 00000000..04628f1e--- /dev/null+++ b/components/skeletons/visitors-table-skeleton.tsx@@ -0,0 +1,23 @@+import { TableCell, TableRow } from "@/components/ui/table";+import { Skeleton } from "../ui/skeleton";++const VisitorsTableSkeleton = () => {+ return (+ <TableRow>+ <TableCell className="min-w-[100px]">+ <Skeleton className="h-6 w-full" />+ </TableCell>+ <TableCell className="min-w-[450px]">+ <Skeleton className="h-6 w-full" />+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-24" />+ </TableCell>+ <TableCell>+ <Skeleton className="h-6 w-24" />+ </TableCell>+ </TableRow>+ );+};++export default VisitorsTableSkeleton;diff --git a/components/visitors/visitor-avatar.tsx b/components/visitors/visitor-avatar.tsxindex 41a0cf6b..65cd83dc 100644--- a/components/visitors/visitor-avatar.tsx+++ b/components/visitors/visitor-avatar.tsx@@ -1,10 +1,13 @@import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { generateGravatarHash } from "@/lib/utils";+import { cn } from "@/lib/utils";export const VisitorAvatar = ({viewerEmail,+ className,}: {viewerEmail: string | null;+ className?: string;}) => {// Convert email string to a simple hashconst hashString = (str: string) => {@@ -36,7 +39,7 @@ export const VisitorAvatar = ({if (!viewerEmail) {return (- <Avatar className="flex-shrink-0 hidden sm:inline-flex">+ <Avatar className={cn("flex-shrink-0 hidden sm:inline-flex", className)}><AvatarFallback className="bg-gray-200/50 dark:bg-gray-200/50">AN</AvatarFallback>@@ -45,7 +48,7 @@ export const VisitorAvatar = ({}return (- <Avatar className="flex-shrink-0 hidden sm:inline-flex">+ <Avatar className={cn("flex-shrink-0 hidden sm:inline-flex", className)}><AvatarImagesrc={`https://gravatar.com/avatar/${generateGravatarHash(viewerEmail,diff --git a/components/visitors/visitor-chart.tsx b/components/visitors/visitor-chart.tsxindex 0f94b1f3..aee4a9ff 100644--- a/components/visitors/visitor-chart.tsx+++ b/components/visitors/visitor-chart.tsx@@ -1,6 +1,7 @@import { useVisitorStats } from "@/lib/swr/use-stats";import ErrorPage from "next/error";import BarChartComponent from "@/components/charts/bar-chart";+import StatsChartSkeleton from "../skeletons/stats-chart-skeleton";export default function VisitorChart({documentId,@@ -18,7 +19,7 @@ export default function VisitorChart({}if (!stats?.duration.data) {- return <div>No data</div>;+ return <StatsChartSkeleton />;}let durationData = Array.from({ length: totalPages }, (_, i) => ({@@ -36,7 +37,7 @@ export default function VisitorChart({});return (- <div className="">+ <div className="pl-0.5 md:pl-1 pb-0.5 md:pb-1 border-l border-b rounded-bl-lg"><BarChartComponent data={durationData} isSum={true} /></div>);diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsxindex ae8e174f..66b0d1f6 100644--- a/components/visitors/visitors-table.tsx+++ b/components/visitors/visitors-table.tsx@@ -15,32 +15,41 @@ import { Gauge } from "@/components/ui/gauge";import { useDocumentVisits } from "@/lib/swr/use-document";import { durationFormat, timeAgo } from "@/lib/utils";-import { Skeleton } from "@/components/ui/skeleton";import ChevronDown from "@/components/shared/icons/chevron-down";import VisitorChart from "./visitor-chart";import { VisitorAvatar } from "./visitor-avatar";import BadgeCheck from "../shared/icons/badge-check";+import VisitorsTableSkeleton from "../skeletons/visitors-table-skeleton";export default function VisitorsTable({ numPages }: { numPages: number }) {const { views } = useDocumentVisits();return (- <div className="w-full sm:p-4">+ <div className="w-full"><div>- <h2 className="p-4">All visitors</h2>+ <h2 className="mb-2 md:mb-4">All visitors</h2></div>- <div className="rounded-md sm:border">+ <div className="rounded-md border"><Table><TableHeader>- <TableRow className="hover:bg-transparent">- <TableHead className="font-medium">Name</TableHead>- <TableHead className="font-medium">Visit Duration</TableHead>- <TableHead className="font-medium">Visit Completion</TableHead>- <TableHead className="font-medium">Last Viewed</TableHead>- <TableHead className="font-medium text-center sm:text-right"></TableHead>+ <TableRow className="hover:bg-transparent *:font-medium *:whitespace-nowrap">+ <TableHead>Name</TableHead>+ <TableHead>Visit Duration</TableHead>+ <TableHead>Visit Completion</TableHead>+ <TableHead>Last Viewed</TableHead>+ <TableHead className="text-center sm:text-right"></TableHead></TableRow></TableHeader><TableBody>+ {views?.length === 0 && (+ <TableRow>+ <TableCell colSpan={5}>+ <div className="w-full h-40 flex items-center justify-center">+ <p>No Data Available</p>+ </div>+ </TableCell>+ </TableRow>+ )}{views ? (views.map((view) => (<Collapsible key={view.id} asChild>@@ -56,15 +65,15 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {{view.viewerEmail ? (<>{view.viewerEmail}{" "}- {view.verified ? (+ {view.verified && (<BadgeCheck className="h-4 w-4 text-emerald-500" />- ) : null}+ )}</>) : ("Anonymous")}</p>- <p className="text-sm text-muted-foreground/60">+ <p className="text-xs sm:text-sm text-muted-foreground/60">{view.link.name ? view.link.name : view.linkId}</p></div>@@ -94,25 +103,24 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {</time></TableCell>{/* Actions */}- <TableCell className="text-center sm:text-right">+ <TableCell className="text-center sm:text-right cursor-pointer p-0"><CollapsibleTrigger asChild>- <div className="flex justify-end px-2 space-x-1 [&[data-state=open]>svg.chevron]:rotate-180">+ <div className="flex justify-end p-5 space-x-1 [&[data-state=open]>svg.chevron]:rotate-180"><ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200 chevron" /></div></CollapsibleTrigger></TableCell></TableRow>+<CollapsibleContent asChild><><TableRow className="hover:bg-transparent"><TableCell colSpan={5}>- <div>- <VisitorChart- documentId={view.documentId}- viewId={view.id}- totalPages={numPages}- />- </div>+ <VisitorChart+ documentId={view.documentId}+ viewId={view.id}+ totalPages={numPages}+ /></TableCell></TableRow></>@@ -121,20 +129,7 @@ export default function VisitorsTable({ numPages }: { numPages: number }) {</Collapsible>))) : (- <TableRow>- <TableCell className="min-w-[100px]">- <Skeleton className="h-6 w-full" />- </TableCell>- <TableCell className="min-w-[450px]">- <Skeleton className="h-6 w-full" />- </TableCell>- <TableCell>- <Skeleton className="h-6 w-24" />- </TableCell>- <TableCell>- <Skeleton className="h-6 w-24" />- </TableCell>- </TableRow>+ <VisitorsTableSkeleton />)}</TableBody></Table>diff --git a/pages/documents/[id]/index.tsx b/pages/documents/[id]/index.tsxindex bb23ab6a..b7c7b2a1 100644--- a/pages/documents/[id]/index.tsx+++ b/pages/documents/[id]/index.tsx@@ -20,16 +20,18 @@ import {DropdownMenuItem,DropdownMenuLabel,DropdownMenuTrigger,+ DropdownMenuSeparator,+ DropdownMenuGroup,} from "@/components/ui/dropdown-menu";import { useRouter } from "next/router";import MoreVertical from "@/components/shared/icons/more-vertical";import { useTeam } from "@/context/team-context";-import ProcessStatusBar from "@/components/documents/process-status-bar";import NotionIcon from "@/components/shared/icons/notion";import PapermarkSparkle from "@/components/shared/icons/papermark-sparkle";import { Document } from "@prisma/client";import { usePlausible } from "next-plausible";import { mutate } from "swr";+import { TrashIcon, Sparkles, LinkIcon } from "lucide-react";export default function DocumentPage() {const { document: prismaDocument, primaryVersion, error } = useDocument();@@ -197,167 +199,187 @@ export default function DocumentPage() {}};+ const activateOrDeactivateAssistant = async (+ active: boolean,+ prismaDocumentId: string,+ ) => {+ const fetchPromise = fetch("/api/assistants", {+ method: active ? "POST" : "DELETE",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ documentId: prismaDocumentId,+ }),+ }).then(() => {+ // refetch to fix the UI delay+ mutate(+ `/api/teams/${teamInfo?.currentTeam?.id}/documents/${prismaDocumentId}`,+ );+ });++ toast.promise(fetchPromise, {+ loading: `${active ? "Activating" : "Deactivating"} Assistant...`,+ success: `Papermark Assistant successfully ${active ? "activated" : "deactivated"}.`,+ error: `${active ? "Activation" : "Deactivation"} failed. Please try again.`,+ });+ };+if (error && error.status === 404) {return <ErrorPage statusCode={404} />;}return (<AppLayout>- <div>+ <main className="relative overflow-hidden mx-2 sm:mx-3 md:mx-5 lg:mx-7 xl:mx-10 mt-4 md:mt-5 lg:mt-8 mb-10 space-y-8 px-1">{prismaDocument && primaryVersion ? (<>- {/* Heading */}- <div className="flex flex-col items-start justify-between gap-x-8 gap-y-4 p-4 sm:flex-row sm:items-center sm:m-4">- <div className="space-y-2">- <div className="flex space-x-4 items-center">- <div className="w-8">- {primaryVersion.type === "notion" ? (- <NotionIcon className="w-8 h-8" />- ) : (- <Image- src={`/_icons/${getExtension(primaryVersion.file)}.svg`}- alt="File icon"- width={50}- height={50}- className=""- />- )}- </div>- <div className="flex flex-col">- <h2- className="leading-7 text-2xl text-foreground font-semibold tracking-tight hover:cursor-text"- ref={nameRef}- contentEditable={true}- onFocus={() => setIsEditingName(true)}- onBlur={handleNameSubmit}- onKeyDown={preventEnterAndSubmit}- title="Click to edit"- dangerouslySetInnerHTML={{ __html: prismaDocument.name }}+ <header className="flex items-center justify-between gap-x-8 !mb-20">+ <div className="flex space-x-2 items-center">+ {primaryVersion.type === "notion" ? (+ <NotionIcon className="w-7 lg:w-8 h-7 lg:h-8" />+ ) : (+ <div className="w-[25px] lg:w-[32px] h-[25px] lg:h-[32px]">+ <Image+ src={`/_icons/${getExtension(primaryVersion.file)}.svg`}+ alt="File icon"+ width={50}+ height={50}/>- {isEditingName && (- <p className="text-sm text-muted-foreground mt-1">- {`You are editing the document name. Press <Enter> to save.`}- </p>- )}</div>+ )}++ <div className="flex flex-col mt-1 lg:mt-0">+ <h2+ className="text-lg lg:text-xl xl:text-2xl text-foreground font-semibold tracking-tight py-0.5 lg:py-1 px-1 lg:px-3 rounded-md border border-transparent hover:cursor-text hover:border hover:border-border focus-visible:text-lg lg:focus-visible:text-xl duration-200"+ ref={nameRef}+ contentEditable={true}+ onFocus={() => setIsEditingName(true)}+ onBlur={handleNameSubmit}+ onKeyDown={preventEnterAndSubmit}+ title="Click to edit"+ dangerouslySetInnerHTML={{ __html: prismaDocument.name }}+ />+ {isEditingName && (+ <span className="text-xs text-muted-foreground mt-1">+ {`Press <Enter> to save the name.`}+ </span>+ )}</div></div>- <div className="flex items-center gap-x-4">- {primaryVersion.type !== "notion" ? (++ <div className="flex items-center gap-x-4 md:gap-x-2 lg:gap-x-4">+ {primaryVersion.type !== "notion" && (<AddDocumentModal newVersion><button title="Upload a new version"><FileUp className="w-6 h-6" /></button></AddDocumentModal>- ) : null}+ )}++ {prismaDocument.type !== "notion" && (+ <Button+ className="group hidden md:flex h-8 lg:h-9 space-x-1 text-xs lg:text-sm whitespace-nowrap bg-gradient-to-r from-[#16222A] via-emerald-500 to-[#16222A] duration-200 ease-linear hover:bg-right"+ variant={"special"}+ style={{ backgroundSize: "200% auto" }}+ onClick={() => activateOrRedirectAssistant(prismaDocument)}+ >+ <PapermarkSparkle className="h-5 w-5 animate-pulse group-hover:animate-none" />{" "}+ <span>AI Assistant</span>+ </Button>+ )}++ <Button+ className="hidden md:flex h-8 lg:h-9 text-xs lg:text-sm whitespace-nowrap"+ onClick={() => setIsLinkSheetOpen(true)}+ >+ Create Link+ </Button>+<DropdownMenuopen={menuOpen}onOpenChange={handleMenuStateChange}><DropdownMenuTrigger asChild>- <Button variant="ghost" className="h-8 w-8 p-0">+ <Button+ variant="outline"+ className="h-8 lg:h-9 w-8 lg:w-9 p-0 bg-transparent"+ ><span className="sr-only">Open menu</span><MoreVertical className="h-4 w-4" /></Button></DropdownMenuTrigger>- <DropdownMenuContent align="end" ref={dropdownRef}>+ <DropdownMenuContent+ align="end"+ className="w-[180px]"+ ref={dropdownRef}+ ><DropdownMenuLabel>Actions</DropdownMenuLabel>- {primaryVersion.type !== "notion" ? (- !prismaDocument.assistantEnabled ? (+ <DropdownMenuGroup className="block md:hidden">+ {prismaDocument.type !== "notion" && (<DropdownMenuItem- onClick={() => {- const fetchPromise = fetch("/api/assistants", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- documentId: prismaDocument.id,- }),- }).then(() => {- // refetch to fix the UI delay- mutate(- `/api/teams/${teamInfo?.currentTeam?.id}/documents/${prismaDocument.id}`,- );- });-- toast.promise(fetchPromise, {- loading: "Activating Assistant...",- success:- "Papermark Assistant successfully activated.",- error: "Activation failed. Please try again.",- });- }}+ onClick={() =>+ activateOrRedirectAssistant(prismaDocument)+ }>- Activate Assistant+ <PapermarkSparkle className="h-4 w-4 animate-pulse group-hover:animate-none mr-2" />+ AI Assistant+ </DropdownMenuItem>+ )}++ <DropdownMenuItem+ onClick={() => setIsLinkSheetOpen(true)}+ >+ <LinkIcon className="h-4 w-4 animate-pulse group-hover:animate-none mr-2" />+ Create Link+ </DropdownMenuItem>++ <DropdownMenuSeparator />+ </DropdownMenuGroup>++ {primaryVersion.type !== "notion" &&+ (!prismaDocument.assistantEnabled ? (+ <DropdownMenuItem+ onClick={() =>+ activateOrDeactivateAssistant(+ true,+ prismaDocument.id,+ )+ }+ >+ <Sparkles className="w-4 h-4 mr-2" /> Activate+ Assistant</DropdownMenuItem>) : (<DropdownMenuItem- onClick={() => {- const fetchPromise = fetch("/api/assistants", {- method: "DELETE",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- documentId: prismaDocument.id,- }),- }).then(() => {- // refetch to fix the UI delay- mutate(- `/api/teams/${teamInfo?.currentTeam?.id}/documents/${prismaDocument.id}`,- );- });-- toast.promise(fetchPromise, {- loading: "Deactivating Assistant...",- success:- "Papermark Assistant successfully de-activated.",- error: "De-activation failed. Please try again.",- });- }}+ onClick={() =>+ activateOrDeactivateAssistant(+ false,+ prismaDocument.id,+ )+ }>- Disable Assistant+ <Sparkles className="w-4 h-4 mr-2" /> Disable+ Assistant</DropdownMenuItem>- )- ) : null}+ ))}++ <DropdownMenuSeparator />+<DropdownMenuItemclassName="text-destructive focus:bg-destructive focus:text-destructive-foreground"onClick={(event) =>handleButtonClick(event, prismaDocument.id)}>+ <TrashIcon className="w-4 h-4 mr-2" />{isFirstClick ? "Really delete?" : "Delete document"}</DropdownMenuItem>{/* create a dropdownmenuitem that onclick calls a post request to /api/assistants with the documentId */}</DropdownMenuContent></DropdownMenu>-- {prismaDocument.type !== "notion" ? (- <Button- className="group space-x-1 bg-gradient-to-r from-[#16222A] via-emerald-500 to-[#16222A] duration-200 ease-linear hover:bg-right"- variant={"special"}- style={{- backgroundSize: "200% auto",- }}- onClick={() => activateOrRedirectAssistant(prismaDocument)}- >- <PapermarkSparkle className="h-5 w-5 animate-pulse group-hover:animate-none" />{" "}- <span>AI Assistant</span>- </Button>- ) : null}-- <Button onClick={() => setIsLinkSheetOpen(true)}>- Create Link- </Button>- </div>- </div>- {/* Progress bar */}- {primaryVersion.type !== "notion" && !primaryVersion.hasPages ? (- <div className="flex flex-col items-start justify-between gap-x-8 gap-y-4 p-4 sm:flex-row sm:items-center sm:m-4">- <ProcessStatusBar documentVersionId={primaryVersion.id} /></div>- ) : null}+ </header>{/* Stats */}{prismaDocument.numPages !== null && (@@ -366,11 +388,15 @@ export default function DocumentPage() {totalPagesMax={primaryVersion.numPages!}/>)}+<StatsCard />+{/* Links */}- <LinksTable />+ <LinksTable primaryVersion={primaryVersion} />+{/* Visitors */}<VisitorsTable numPages={primaryVersion.numPages!} />+<LinkSheetisOpen={isLinkSheetOpen}setIsOpen={setIsLinkSheetOpen}@@ -381,7 +407,7 @@ export default function DocumentPage() {<LoadingSpinner className="mr-1 h-20 w-20" /></div>)}- </div>+ </main></AppLayout>);}