Skip to content

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

feat: small fixes

Iuliia Shnai1c8ba81bd537
diff --git a/components/agreements/agreement-card.tsx b/components/agreements/agreement-row.tsx
similarity index 68%
rename from components/agreements/agreement-card.tsx
rename to components/agreements/agreement-row.tsx
index a1e949a2..4208592b 100644
--- a/components/agreements/agreement-card.tsx
+++ b/components/agreements/agreement-row.tsx
@@ -7,7 +7,7 @@ import {
FileSignatureIcon,
FileTextIcon,
Link2Icon,
- MoreVertical,
+ MoreHorizontalIcon,
PencilIcon,
ServerIcon,
TrashIcon,
@@ -43,6 +43,7 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Skeleton } from "@/components/ui/skeleton";
+import { TableCell, TableRow } from "@/components/ui/table";
import { TimestampTooltip } from "@/components/ui/timestamp-tooltip";
import {
Tooltip,
@@ -52,17 +53,13 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
-interface AgreementCardProps {
+interface AgreementRowProps {
agreement: AgreementWithLinksCount;
onDelete: (id: string) => void;
onEdit: (agreement: AgreementWithLinksCount) => void;
}
-function AgreementCard({
- agreement,
- onDelete,
- onEdit,
-}: AgreementCardProps) {
+function AgreementRow({ agreement, onDelete, onEdit }: AgreementRowProps) {
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
@@ -80,7 +77,9 @@ function AgreementCard({
responses,
loading: responsesLoading,
error: responsesError,
- } = useAgreementResponses(isExpanded && isSigningAgreement ? agreement.id : null);
+ } = useAgreementResponses(
+ isExpanded && isSigningAgreement ? agreement.id : null,
+ );
const handleDelete = async () => {
if (!teamId) return;
@@ -104,12 +103,9 @@ function AgreementCard({
const handleDownload = async () => {
if (!teamId) return;
toast.promise(
- fetch(
- `/api/teams/${teamId}/agreements/${agreement.id}/download`,
- {
- method: "POST",
- },
- ).then(async (response) => {
+ fetch(`/api/teams/${teamId}/agreements/${agreement.id}/download`, {
+ method: "POST",
+ }).then(async (response) => {
if (!response.ok) {
throw new Error("Failed to download agreement");
}
@@ -173,128 +169,118 @@ function AgreementCard({
return (
<>
- <div className="rounded-lg border">
- <div className="flex items-center justify-between p-4">
- <div className="flex items-center space-x-4">
- <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted">
- {isSigningAgreement ? (
- <FileSignatureIcon className="h-5 w-5" />
- ) : (
- <FileTextIcon className="h-5 w-5" />
- )}
- </div>
- <div>
- <h3 className="font-medium">{agreement.name}</h3>
- <p className="text-sm text-muted-foreground">
- Last updated{" "}
- {new Date(agreement.updatedAt).toLocaleDateString()}
- </p>
- </div>
- </div>
-
- <div className="flex items-center gap-x-2">
- <div className="text-sm text-muted-foreground">
- {agreement._count?.links || 0}{" "}
- {agreement._count?.links === 1 ? "link" : "links"}
- </div>
+ <TableRow className="hover:bg-transparent">
+ <TableCell>
+ <div className="flex items-center gap-2">
{isSigningAgreement ? (
+ <FileSignatureIcon className="h-4 w-4 text-gray-400" />
+ ) : (
+ <FileTextIcon className="h-4 w-4 text-gray-400" />
+ )}
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {agreement.name}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {agreement._count?.links || 0}{" "}
+ {agreement._count?.links === 1 ? "link" : "links"}
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {new Date(agreement.updatedAt).toLocaleDateString()}
+ </TableCell>
+ <TableCell
+ className="text-right"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
<Button
+ type="button"
variant="ghost"
- size="sm"
- className="hidden h-8 gap-x-1 px-2 text-xs text-muted-foreground sm:flex"
- onClick={() => setIsExpanded((prev) => !prev)}
- aria-expanded={isExpanded}
+ size="icon"
+ className="h-8 w-8"
+ aria-label="Open agreement actions"
>
- {isExpanded ? "Hide signed" : "Show signed"}
- <ChevronDownIcon
- className={cn(
- "h-4 w-4 transition-transform",
- isExpanded && "rotate-180",
- )}
- />
+ <MoreHorizontalIcon className="!h-4 !w-4" />
</Button>
- ) : null}
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="h-8 w-8 p-0">
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <TooltipProvider delayDuration={0}>
- <Tooltip>
- <TooltipTrigger asChild>
- <DropdownMenuItem
- aria-disabled={disableEdit}
- className={cn(
- disableEdit &&
- "cursor-not-allowed opacity-50 focus:bg-transparent focus:text-muted-foreground",
- )}
- onSelect={(event) => {
- if (disableEdit) {
- event.preventDefault();
- return;
- }
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ <TooltipProvider delayDuration={0}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuItem
+ aria-disabled={disableEdit}
+ className={cn(
+ disableEdit &&
+ "cursor-not-allowed opacity-50 focus:bg-transparent focus:text-muted-foreground",
+ )}
+ onSelect={(event) => {
+ if (disableEdit) {
+ event.preventDefault();
+ return;
+ }
- onEdit(agreement);
- }}
+ onEdit(agreement);
+ }}
+ >
+ <PencilIcon className="mr-2 h-4 w-4" />
+ Edit agreement
+ </DropdownMenuItem>
+ </TooltipTrigger>
+ {disableEdit ? (
+ <TooltipPortal>
+ <TooltipContent
+ side="left"
+ sideOffset={8}
+ className="max-w-64 text-center text-xs"
>
- <PencilIcon className="mr-2 h-4 w-4" />
- Edit agreement
- </DropdownMenuItem>
- </TooltipTrigger>
- {disableEdit ? (
- <TooltipPortal>
- <TooltipContent
- side="left"
- sideOffset={8}
- className="max-w-64 text-center text-xs"
- >
- {disabledEditReason}
- </TooltipContent>
- </TooltipPortal>
- ) : null}
- </Tooltip>
- </TooltipProvider>
- {isSigningAgreement ? (
- <DropdownMenuItem
- onClick={() => setIsExpanded((prev) => !prev)}
- className="sm:hidden"
- >
- <FileSignatureIcon className="mr-2 h-4 w-4" />
- {isExpanded ? "Hide signed NDAs" : "Show signed NDAs"}
- </DropdownMenuItem>
- ) : null}
- {!isSigningAgreement ? (
- <DropdownMenuItem onClick={handleDownload}>
- <DownloadIcon className="mr-2 h-4 w-4" />
- Download agreement
- </DropdownMenuItem>
- ) : null}
+ {disabledEditReason}
+ </TooltipContent>
+ </TooltipPortal>
+ ) : null}
+ </Tooltip>
+ </TooltipProvider>
+ {isSigningAgreement ? (
<DropdownMenuItem
- className="text-destructive focus:bg-destructive focus:text-destructive-foreground"
- onClick={() => setShowDeleteDialog(true)}
+ onClick={() => setIsExpanded((prev) => !prev)}
>
- <TrashIcon className="mr-2 h-4 w-4" />
- Delete agreement
+ <FileSignatureIcon className="mr-2 h-4 w-4" />
+ {isExpanded ? "Hide signed NDAs" : "Show signed NDAs"}
</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </div>
+ ) : null}
+ {!isSigningAgreement ? (
+ <DropdownMenuItem onClick={handleDownload}>
+ <DownloadIcon className="mr-2 h-4 w-4" />
+ Download agreement
+ </DropdownMenuItem>
+ ) : null}
+ <DropdownMenuItem
+ className="text-destructive focus:bg-destructive focus:text-destructive-foreground"
+ onClick={() => setShowDeleteDialog(true)}
+ >
+ <TrashIcon className="mr-2 h-4 w-4" />
+ Delete agreement
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
- {isExpanded && isSigningAgreement ? (
- <div className="border-t bg-muted/20 px-4 py-3">
- <AgreementResponsesSection
- loading={responsesLoading}
- error={!!responsesError}
- responses={responses}
- onDownload={handleDownloadResponse}
- />
- </div>
- ) : null}
- </div>
+ {isExpanded && isSigningAgreement ? (
+ <TableRow className="hover:bg-transparent">
+ <TableCell colSpan={4} className="bg-muted/20 p-0">
+ <div className="px-4 py-3">
+ <AgreementResponsesSection
+ loading={responsesLoading}
+ error={!!responsesError}
+ responses={responses}
+ onDownload={handleDownloadResponse}
+ />
+ </div>
+ </TableCell>
+ </TableRow>
+ ) : null}
<AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
<AlertDialogContent>
@@ -327,7 +313,7 @@ function AgreementCard({
);
}
-export default memo(AgreementCard);
+export default memo(AgreementRow);
function AgreementResponsesSection({
loading,
@@ -376,9 +362,7 @@ function AgreementResponsesSection({
</li>
{responses.map((response) => {
const signedAt =
- response.signedAt ||
- response.completedAt ||
- response.createdAt;
+ response.signedAt || response.completedAt || response.createdAt;
const signerLabel =
response.view?.viewerName ||
response.view?.viewerEmail ||
@@ -411,7 +395,7 @@ function AgreementResponsesSection({
key={response.id}
className="flex flex-col gap-2 py-3 md:flex-row md:items-center md:gap-3"
>
- <div className="flex flex-1 items-center gap-2 min-w-0">
+ <div className="flex min-w-0 flex-1 items-center gap-2">
<div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600">
<FileSignatureIcon className="h-4 w-4" />
</div>
diff --git a/components/billing/upgrade-plan-modal-with-discount.tsx b/components/billing/upgrade-plan-modal-with-discount.tsx
index 31a1dd1f..fa33db19 100644
--- a/components/billing/upgrade-plan-modal-with-discount.tsx
+++ b/components/billing/upgrade-plan-modal-with-discount.tsx
@@ -45,7 +45,7 @@ const StartDataRoomTrialButton = ({ teamId }: { teamId?: string }) => {
onClick={handleStartTrial}
className="cursor-pointer underline underline-offset-4 hover:text-foreground"
>
- Start free data room plus plan trial
+ Start free Data Rooms Plus trial
</span>
);
};
@@ -253,313 +253,317 @@ export function UpgradePlanModalWithDiscount({
}}
>
<div className="pt-10 sm:pt-0">
- <div className="flex flex-col lg:flex-row">
- {/* Left Sidebar - Discount Information */}
- <div className="flex h-full w-full flex-col border-b border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-900 lg:w-64 lg:border-b-0 lg:border-r">
- <div className="mb-2">
- <h2 className="text-sm font-bold uppercase text-[#fb7a00]">
- SWITCH TO YEARLY
- </h2>
- </div>
- <p className="mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
- Save <span className="font-bold text-[#fb7a00]">30%</span> on
- yearly plans
- </p>
-
- {/* Decorative elements - Holiday section - Centered vertically */}
- <div className="relative flex flex-1 flex-col items-center justify-center">
- <div className="mb-3 h-16 w-16 text-[#fb7a00] opacity-30">
- <Sparkles className="h-full w-full" />
+ <div className="flex flex-col lg:flex-row">
+ {/* Left Sidebar - Discount Information */}
+ <div className="flex h-full w-full flex-col border-b border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-900 lg:w-64 lg:border-b-0 lg:border-r">
+ <div className="mb-2">
+ <h2 className="text-sm font-bold uppercase text-[#fb7a00]">
+ SWITCH TO YEARLY
+ </h2>
</div>
- <div className="flex w-full items-center gap-2">
- <div className="h-px flex-1 bg-[#fb7a00]"></div>
- <p className="text-sm font-semibold text-[#fb7a00]">NEW YEAR&apos;S</p>
- <div className="h-px flex-1 bg-[#fb7a00]"></div>
- </div>
- <p className="mt-2 text-xs text-gray-600 dark:text-gray-400">
- New Year&apos;s offer
+ <p className="mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
+ Save <span className="font-bold text-[#fb7a00]">30%</span> on
+ yearly plans
</p>
- {/* <div className="absolute bottom-0 h-12 w-12 text-[#fb7a00] opacity-20">
+
+ {/* Decorative elements - Holiday section - Centered vertically */}
+ <div className="relative flex flex-1 flex-col items-center justify-center">
+ <div className="mb-3 h-16 w-16 text-[#fb7a00] opacity-30">
+ <Sparkles className="h-full w-full" />
+ </div>
+ <div className="flex w-full items-center gap-2">
+ <div className="h-px flex-1 bg-[#fb7a00]"></div>
+ <p className="text-sm font-semibold text-[#fb7a00]">
+ NEW YEAR&apos;S
+ </p>
+ <div className="h-px flex-1 bg-[#fb7a00]"></div>
+ </div>
+ <p className="mt-2 text-xs text-gray-600 dark:text-gray-400">
+ New Year&apos;s offer
+ </p>
+ {/* <div className="absolute bottom-0 h-12 w-12 text-[#fb7a00] opacity-20">
<Sparkles className="h-full w-full" />
</div> */}
- </div>
-
- <p className="mt-6 text-center text-xs text-gray-500 dark:text-gray-400">
- Ends Jan 15 2026
- </p>
- </div>
+ </div>
- {/* Right Content - Plans */}
- <div className="flex-1 p-6">
- {/* Monthly/Yearly Toggle */}
- <div className="mb-6 flex items-center justify-center">
- <span className="mr-2 text-sm">
- Monthly{" "}
- {period === "monthly" && (
- <span className="text-[#fb7a00]"></span>
- )}
- </span>
- <Switch
- checked={period === "yearly"}
- onCheckedChange={() =>
- setPeriod(period === "monthly" ? "yearly" : "monthly")
- }
- />
- <span className="ml-2 text-sm">Annually</span>
+ <p className="mt-6 text-center text-xs text-gray-500 dark:text-gray-400">
+ Ends Jan 15 2026
+ </p>
</div>
- <div className="isolate grid grid-cols-1 gap-4 overflow-hidden rounded-xl p-4 md:grid-cols-2">
- {plansToShow.map((planOption) => {
- const isDataRoomsUpgrade = plansToShow.includes(
- PlanEnum.DataRooms,
- );
-
- // Determine which plan to show based on selection for Data Rooms
- let effectivePlan = planOption;
- let displayPlanName = planOption;
-
- if (planOption === PlanEnum.DataRooms && isDataRoomsUpgrade) {
- if (dataRoomsPlanSelection === "plus") {
- effectivePlan = PlanEnum.DataRoomsPlus;
- displayPlanName = PlanEnum.DataRoomsPlus;
- } else if (dataRoomsPlanSelection === "premium") {
- effectivePlan = PlanEnum.DataRoomsPremium;
- displayPlanName = PlanEnum.DataRoomsPremium;
+ {/* Right Content - Plans */}
+ <div className="flex-1 p-6">
+ {/* Monthly/Yearly Toggle */}
+ <div className="mb-6 flex items-center justify-center">
+ <span className="mr-2 text-sm">
+ Monthly{" "}
+ {period === "monthly" && (
+ <span className="text-[#fb7a00]"></span>
+ )}
+ </span>
+ <Switch
+ checked={period === "yearly"}
+ onCheckedChange={() =>
+ setPeriod(period === "monthly" ? "yearly" : "monthly")
}
- }
-
- const planFeatures = getPlanFeatures(effectivePlan, {
- period,
- });
-
- const planData = PLANS.find((p) => p.name === displayPlanName);
- const monthlyPrice = planData?.price.monthly.amount || 0;
- const yearlyPrice = planData?.price.yearly.amount || 0;
- const discountedYearlyPrice =
- getDiscountedYearlyPrice(yearlyPrice);
-
- // Determine if this plan should have orange styling
- const isOrangePlan = isFree
- ? displayPlanName === PlanEnum.Business ||
- displayPlanName === PlanEnum.DataRoomsPlus
- : displayPlanName === nextHigherPlan;
-
- return (
- <div
- key={displayPlanName}
- className={`relative flex flex-col rounded-lg border ${
- isOrangePlan
- ? "border-[#fb7a00]"
- : "border-gray-200 dark:border-gray-700"
- } bg-white p-6 shadow-sm dark:bg-gray-900`}
- >
- <div className="mb-4 border-b border-gray-200 pb-2 dark:border-gray-700">
- <div className="flex items-center justify-between">
- <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
- {displayPlanName}
- </h3>
+ />
+ <span className="ml-2 text-sm">Annually</span>
+ </div>
+
+ <div className="isolate grid grid-cols-1 gap-4 overflow-hidden rounded-xl p-4 md:grid-cols-2">
+ {plansToShow.map((planOption) => {
+ const isDataRoomsUpgrade = plansToShow.includes(
+ PlanEnum.DataRooms,
+ );
+
+ // Determine which plan to show based on selection for Data Rooms
+ let effectivePlan = planOption;
+ let displayPlanName = planOption;
+
+ if (planOption === PlanEnum.DataRooms && isDataRoomsUpgrade) {
+ if (dataRoomsPlanSelection === "plus") {
+ effectivePlan = PlanEnum.DataRoomsPlus;
+ displayPlanName = PlanEnum.DataRoomsPlus;
+ } else if (dataRoomsPlanSelection === "premium") {
+ effectivePlan = PlanEnum.DataRoomsPremium;
+ displayPlanName = PlanEnum.DataRoomsPremium;
+ }
+ }
+
+ const planFeatures = getPlanFeatures(effectivePlan, {
+ period,
+ });
+
+ const planData = PLANS.find(
+ (p) => p.name === displayPlanName,
+ );
+ const monthlyPrice = planData?.price.monthly.amount || 0;
+ const yearlyPrice = planData?.price.yearly.amount || 0;
+ const discountedYearlyPrice =
+ getDiscountedYearlyPrice(yearlyPrice);
+
+ // Determine if this plan should have orange styling
+ const isOrangePlan = isFree
+ ? displayPlanName === PlanEnum.Business ||
+ displayPlanName === PlanEnum.DataRoomsPlus
+ : displayPlanName === nextHigherPlan;
+
+ return (
+ <div
+ key={displayPlanName}
+ className={`relative flex flex-col rounded-lg border ${
+ isOrangePlan
+ ? "border-[#fb7a00]"
+ : "border-gray-200 dark:border-gray-700"
+ } bg-white p-6 shadow-sm dark:bg-gray-900`}
+ >
+ <div className="mb-4 border-b border-gray-200 pb-2 dark:border-gray-700">
+ <div className="flex items-center justify-between">
+ <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
+ {displayPlanName}
+ </h3>
+ </div>
+ {period === "yearly" &&
+ (() => {
+ const monthlyForYear = monthlyPrice * 12;
+ const yearlyWithDiscount = Math.round(
+ yearlyPrice * 12 * 0.7,
+ );
+ const savings = monthlyForYear - yearlyWithDiscount;
+ return savings > 0 ? (
+ <span className="absolute right-2 top-2 rounded bg-[#fb7a00]/10 px-2 py-1 text-xs font-medium text-[#fb7a00]">
+ Save €{savings}/year
+ </span>
+ ) : null;
+ })()}
+ {period === "monthly" && isOrangePlan && (
+ <span className="absolute right-2 top-2 rounded bg-[#fb7a00] px-2 py-1 text-xs text-white">
+ {displayPlanName === PlanEnum.Business &&
+ "Most popular"}
+ {displayPlanName === PlanEnum.DataRoomsPlus &&
+ "Best deal"}
+ </span>
+ )}
</div>
- {period === "yearly" &&
- (() => {
- const monthlyForYear = monthlyPrice * 12;
- const yearlyWithDiscount = Math.round(
- yearlyPrice * 12 * 0.7,
- );
- const savings = monthlyForYear - yearlyWithDiscount;
- return savings > 0 ? (
- <span className="absolute right-2 top-2 rounded bg-[#fb7a00]/10 px-2 py-1 text-xs font-medium text-[#fb7a00]">
- Save €{savings}/year
- </span>
- ) : null;
- })()}
- {period === "monthly" && isOrangePlan && (
- <span className="absolute right-2 top-2 rounded bg-[#fb7a00] px-2 py-1 text-xs text-white">
- {displayPlanName === PlanEnum.Business &&
- "Most popular"}
- {displayPlanName === PlanEnum.DataRoomsPlus &&
- "Best deal"}
- </span>
- )}
- </div>
- <div className="mb-2">
- {period === "yearly" ? (
- // Yearly: Show discounted price with crossed out original
- <>
- <div className="flex items-baseline gap-2">
- <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
- €{discountedYearlyPrice}
- </span>
- <span className="text-xl text-gray-500 line-through">
- €{yearlyPrice}
+ <div className="mb-2">
+ {period === "yearly" ? (
+ // Yearly: Show discounted price with crossed out original
+ <>
+ <div className="flex items-baseline gap-2">
+ <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
+ €{discountedYearlyPrice}
+ </span>
+ <span className="text-xl text-gray-500 line-through">
+ €{yearlyPrice}
+ </span>
+ </div>
+ <span className="text-gray-500 dark:text-white/75">
+ /month, billed annually
</span>
- </div>
- <span className="text-gray-500 dark:text-white/75">
- /month, billed annually
- </span>
- </>
- ) : (
- // Monthly: Show regular monthly price (no discount)
- <>
- <div className="flex items-baseline gap-2">
- <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
- €{monthlyPrice}
+ </>
+ ) : (
+ // Monthly: Show regular monthly price (no discount)
+ <>
+ <div className="flex items-baseline gap-2">
+ <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
+ €{monthlyPrice}
+ </span>
+ </div>
+ <span className="text-gray-500 dark:text-white/75">
+ /month
</span>
- </div>
- <span className="text-gray-500 dark:text-white/75">
- /month
- </span>
- </>
- )}
- </div>
+ </>
+ )}
+ </div>
- {planOption === PlanEnum.DataRooms &&
- isDataRoomsUpgrade &&
- !plansToShow.includes(PlanEnum.DataRoomsPlus) && (
- <PlanSelector
- value={dataRoomsPlanSelection}
- onChange={setDataRoomsPlanSelection}
- />
- )}
-
- <p className="mt-4 text-sm text-gray-600 dark:text-white">
- {planFeatures.featureIntro}
- </p>
-
- <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-gray-300">
- {planFeatures.features.map((feature, i) => (
- <li key={i}>
- <FeatureItem
- feature={{
- ...feature,
- isHighlighted: highlightItem?.includes(
- feature.id,
- ),
- }}
+ {planOption === PlanEnum.DataRooms &&
+ isDataRoomsUpgrade &&
+ !plansToShow.includes(PlanEnum.DataRoomsPlus) && (
+ <PlanSelector
+ value={dataRoomsPlanSelection}
+ onChange={setDataRoomsPlanSelection}
/>
- </li>
- ))}
- </ul>
-
- <div className="mt-auto">
- <Button
- variant={isOrangePlan ? "default" : "outline"}
- className={`w-full py-2 text-sm ${
- isOrangePlan
- ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
- : "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200"
- }`}
- loading={selectedPlan === planOption}
- disabled={selectedPlan !== null}
- onClick={() => {
- const priceId = getPriceIdFromPlan({
- planName: displayPlanName,
- period,
- isOld: isOldAccount,
- });
-
- setSelectedPlan(planOption);
- // Apply 30% coupon only for yearly plans
- // Uses same logic as retention flow: getCouponFromPlan() in API routes
- const applyDiscount = period === "yearly";
- if (isCustomer && teamPlan !== "free") {
- // For existing customers: Apply coupon directly to subscription (same as retention flow)
- fetch(`/api/teams/${teamId}/billing/manage`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- priceId,
- upgradePlan: true,
- applyYearlyDiscount: applyDiscount, // Only true for yearly plans
- }),
- })
- .then(async (res) => {
- if (!res.ok) {
- const errorData = await res
- .json()
- .catch(() => null);
- const errorMessage =
- errorData?.error ||
- errorData?.message ||
- res.statusText ||
- "Failed to upgrade plan";
- throw new Error(errorMessage);
- }
- const url = await res.json();
- router.push(url);
- })
- .catch((err) => {
- alert(err.message || err);
- setSelectedPlan(null);
- });
- } else {
- // For new customers: Add coupon to Stripe checkout session
- fetch(
- `/api/teams/${teamId}/billing/upgrade?priceId=${priceId}${applyDiscount ? "&applyYearlyDiscount=true" : ""}`,
- {
+ )}
+
+ <p className="mt-4 text-sm text-gray-600 dark:text-white">
+ {planFeatures.featureIntro}
+ </p>
+
+ <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-gray-300">
+ {planFeatures.features.map((feature, i) => (
+ <li key={i}>
+ <FeatureItem
+ feature={{
+ ...feature,
+ isHighlighted: highlightItem?.includes(
+ feature.id,
+ ),
+ }}
+ />
+ </li>
+ ))}
+ </ul>
+
+ <div className="mt-auto">
+ <Button
+ variant={isOrangePlan ? "default" : "outline"}
+ className={`w-full py-2 text-sm ${
+ isOrangePlan
+ ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
+ : "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ const priceId = getPriceIdFromPlan({
+ planName: displayPlanName,
+ period,
+ isOld: isOldAccount,
+ });
+
+ setSelectedPlan(planOption);
+ // Apply 30% coupon only for yearly plans
+ // Uses same logic as retention flow: getCouponFromPlan() in API routes
+ const applyDiscount = period === "yearly";
+ if (isCustomer && teamPlan !== "free") {
+ // For existing customers: Apply coupon directly to subscription (same as retention flow)
+ fetch(`/api/teams/${teamId}/billing/manage`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- },
- )
- .then(async (res) => {
- if (!res.ok) {
- const errorData = await res
- .json()
- .catch(() => null);
- const errorMessage =
- errorData?.error ||
- errorData?.message ||
- res.statusText ||
- "Failed to start checkout";
- throw new Error(errorMessage);
- }
- const data = await res.json();
- const { id: sessionId } = data;
- const stripe = await getStripe(isOldAccount);
- stripe?.redirectToCheckout({ sessionId });
+ body: JSON.stringify({
+ priceId,
+ upgradePlan: true,
+ applyYearlyDiscount: applyDiscount, // Only true for yearly plans
+ }),
})
- .catch((err) => {
- alert(err.message || err);
- setSelectedPlan(null);
- });
- }
- }}
- >
- {selectedPlan === planOption
- ? "Redirecting to Stripe..."
- : `Upgrade to ${displayPlanName} ${capitalize(period)}`}
- </Button>
+ .then(async (res) => {
+ if (!res.ok) {
+ const errorData = await res
+ .json()
+ .catch(() => null);
+ const errorMessage =
+ errorData?.error ||
+ errorData?.message ||
+ res.statusText ||
+ "Failed to upgrade plan";
+ throw new Error(errorMessage);
+ }
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err.message || err);
+ setSelectedPlan(null);
+ });
+ } else {
+ // For new customers: Add coupon to Stripe checkout session
+ fetch(
+ `/api/teams/${teamId}/billing/upgrade?priceId=${priceId}${applyDiscount ? "&applyYearlyDiscount=true" : ""}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ )
+ .then(async (res) => {
+ if (!res.ok) {
+ const errorData = await res
+ .json()
+ .catch(() => null);
+ const errorMessage =
+ errorData?.error ||
+ errorData?.message ||
+ res.statusText ||
+ "Failed to start checkout";
+ throw new Error(errorMessage);
+ }
+ const data = await res.json();
+ const { id: sessionId } = data;
+ const stripe = await getStripe(isOldAccount);
+ stripe?.redirectToCheckout({ sessionId });
+ })
+ .catch((err) => {
+ alert(err.message || err);
+ setSelectedPlan(null);
+ });
+ }
+ }}
+ >
+ {selectedPlan === planOption
+ ? "Redirecting to Stripe..."
+ : `Upgrade to ${displayPlanName} ${capitalize(period)}`}
+ </Button>
+ </div>
</div>
- </div>
- );
- })}
- </div>
- <div className="mt-6 flex flex-col items-center text-center text-sm text-muted-foreground">
- All plans include unlimited visitors and page by page document
- analytics.
- <div className="flex items-center gap-2">
- <Link
- href="/settings/upgrade-holiday-offer"
- className="underline underline-offset-4 hover:text-foreground"
- >
- See all plans
- </Link>
- {((teamPlan === "free" && !isTrial) ||
- (teamPlan === "pro" && !isTrial)) && (
- <>
- <span>|</span>
- <StartDataRoomTrialButton teamId={teamId} />
- </>
- )}
+ );
+ })}
+ </div>
+ <div className="mt-6 flex flex-col items-center text-center text-sm text-muted-foreground">
+ All plans include unlimited visitors and page by page document
+ analytics.
+ <div className="flex items-center gap-2">
+ <Link
+ href="/settings/upgrade-holiday-offer"
+ className="underline underline-offset-4 hover:text-foreground"
+ >
+ See all plans
+ </Link>
+ {((teamPlan === "free" && !isTrial) ||
+ (teamPlan === "pro" && !isTrial)) && (
+ <>
+ <span>|</span>
+ <StartDataRoomTrialButton teamId={teamId} />
+ </>
+ )}
+ </div>
</div>
</div>
</div>
</div>
- </div>
</DialogContent>
</Dialog>
);
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsx
index 282fcc4b..de841a74 100644
--- a/components/billing/upgrade-plan-modal.tsx
+++ b/components/billing/upgrade-plan-modal.tsx
@@ -1,21 +1,21 @@
import Link from "next/link";
import { useRouter } from "next/router";
-import { useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import React from "react";
-import { UnlimitedPlanModal } from "@/components/billing/unlimited-plan-modal";
import { useTeam } from "@/context/team-context";
import { getStripe } from "@/ee/stripe/client";
import { Feature, PlanEnum, getPlanFeatures } from "@/ee/stripe/constants";
import { getPriceIdFromPlan } from "@/ee/stripe/functions/get-price-id-from-plan";
import { PLANS } from "@/ee/stripe/utils";
-import { CheckIcon, CircleHelpIcon, Users2Icon, XIcon } from "lucide-react";
+import { CheckIcon, CircleHelpIcon, UserPlusIcon, XIcon } from "lucide-react";
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
import { capitalize, cn } from "@/lib/utils";
+import { UnlimitedPlanModal } from "@/components/billing/unlimited-plan-modal";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { Switch } from "@/components/ui/switch";
@@ -40,7 +40,7 @@ const StartDataRoomTrialButton = ({ teamId }: { teamId?: string }) => {
onClick={handleStartTrial}
className="cursor-pointer underline underline-offset-4 hover:text-foreground"
>
- Start free data room plus plan trial
+ Start free Data Rooms Plus trial
</span>
);
};
@@ -71,7 +71,7 @@ const FeatureItem = ({
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
+ <UserPlusIcon className="h-4 w-4 text-gray-500" />
</div>
</TooltipTrigger>
<TooltipContent side="left" className="max-w-xs">
@@ -161,6 +161,16 @@ const PlanSelector = ({
);
};
+// Popups whose primary subject is data rooms (opened from the data rooms tab
+// or the trial flow). In these contexts the "Unlimited data rooms" line is kept
+// on the Plus/Premium cards; elsewhere it's only shown on the base Data Rooms
+// card to avoid repeating it.
+const DATAROOM_CONTEXT_TRIGGERS = [
+ "datarooms",
+ "sidebar_datarooms",
+ "dataroom_trial_form",
+];
+
export function UpgradePlanModal({
clickedPlan,
trigger,
@@ -193,6 +203,41 @@ export function UpgradePlanModal({
>("base");
const [unlimitedModalOpen, setUnlimitedModalOpen] = useState(false);
+ // Only show the "pinned" styling (sticky button border/shadow, footer divider)
+ // when the cards actually overflow. When everything fits, it reads as one panel.
+ const [isScrollable, setIsScrollable] = useState(false);
+ const scrollElRef = useRef<HTMLDivElement | null>(null);
+ const resizeObserverRef = useRef<ResizeObserver | null>(null);
+
+ const measureScrollable = useCallback(() => {
+ const el = scrollElRef.current;
+ if (el) {
+ setIsScrollable(el.scrollHeight > el.clientHeight + 1);
+ }
+ }, []);
+
+ const scrollRefCallback = useCallback(
+ (node: HTMLDivElement | null) => {
+ resizeObserverRef.current?.disconnect();
+ scrollElRef.current = node;
+ if (node) {
+ const observer = new ResizeObserver(() => measureScrollable());
+ observer.observe(node);
+ for (const child of Array.from(node.children)) {
+ observer.observe(child);
+ }
+ resizeObserverRef.current = observer;
+ measureScrollable();
+ }
+ },
+ [measureScrollable],
+ );
+
+ // Re-measure when content that affects height changes.
+ useEffect(() => {
+ measureScrollable();
+ }, [open, period, dataRoomsPlanSelection, measureScrollable]);
+
const plansToShow = useMemo(() => {
switch (clickedPlan) {
case PlanEnum.Pro:
@@ -212,6 +257,24 @@ export function UpgradePlanModal({
}
}, [clickedPlan]);
+ // When the popup is about data rooms (data rooms tab / trial), keep the
+ // "Unlimited data rooms" line on the Plus & Premium cards too.
+ const isDataRoomContextPopup = DATAROOM_CONTEXT_TRIGGERS.includes(
+ trigger ?? "",
+ );
+ // Views that only render the Plus/Premium tiers have no base Data Rooms card,
+ // so the line must stay visible there.
+ const onlyPlusAndPremiumShown =
+ !plansToShow.includes(PlanEnum.Pro) &&
+ !plansToShow.includes(PlanEnum.Business) &&
+ !plansToShow.includes(PlanEnum.DataRooms);
+ // Feature-specific upsells (e.g. API, SSO) highlight a particular feature.
+ // There the generic "Unlimited data rooms" line shouldn't be repeated on
+ // every plan card.
+ const hasSpecificFeatureHighlight = !!highlightItem?.some(
+ (item) => item !== "datarooms",
+ );
+
// Track analytics event when modal is opened
useEffect(() => {
if (open) {
@@ -243,401 +306,509 @@ export function UpgradePlanModal({
<DialogTrigger asChild>{buttonChild}</DialogTrigger>
<DialogContent
mobileFullScreen
- className="max-h-[90vh] min-h-fit overflow-y-auto bg-gray-50 text-foreground dark:bg-gray-900"
+ className="max-h-[90vh] min-h-fit overflow-hidden bg-gray-50 p-0 text-foreground dark:bg-gray-900"
style={{
width: "90vw",
maxWidth: "900px",
}}
>
- <div className="flex flex-col gap-4 p-4 pt-12 sm:p-0">
- {trigger === "invite_team_members" && (
- <p
- className="cursor-pointer text-center text-sm text-muted-foreground transition-colors hover:text-foreground"
- onClick={() => setUnlimitedModalOpen(true)}
- >
- Interested in unlimited seats?{" "}
- <span className="font-light underline underline-offset-4">
- Get unlimited
- </span>
- </p>
- )}
-
- <div className="flex items-center justify-center">
- <span className="mr-2 text-sm">Monthly</span>
- <Switch
- checked={period === "yearly"}
- onCheckedChange={() =>
- setPeriod(period === "monthly" ? "yearly" : "monthly")
- }
- />
- <span className="ml-2 text-sm">
- Annually <span className="text-[#fb7a00]">(Save up to 35%)</span>
- </span>
- </div>
-
- {plansToShow.some(
- (p) =>
- p === PlanEnum.DataRooms ||
- p === PlanEnum.DataRoomsPlus ||
- p === PlanEnum.DataRoomsPremium,
- ) &&
- trigger !== "invite_team_members" && (
- <p
- className="cursor-pointer text-center text-sm text-muted-foreground transition-colors hover:text-foreground"
- onClick={() => setUnlimitedModalOpen(true)}
- >
- Deals with everything unlimited?{" "}
- <span className="font-light underline underline-offset-4">
- Get unlimited members, storage, and data rooms in one plan.
+ <div className="flex max-h-[95vh] flex-col max-sm:h-full max-sm:max-h-none">
+ {/* Fixed header — billing period toggle stays visible while the cards scroll */}
+ <div className="flex-none bg-gray-50 px-4 pb-5 pt-10 dark:bg-gray-900 sm:px-6 sm:pb-5 sm:pt-6">
+ <div className="flex items-center justify-center">
+ <span className="mr-2 text-sm">Monthly</span>
+ <Switch
+ checked={period === "yearly"}
+ onCheckedChange={() =>
+ setPeriod(period === "monthly" ? "yearly" : "monthly")
+ }
+ />
+ <span className="ml-2 text-sm">
+ Annually{" "}
+ <span className="text-[#fb7a00]">(Save up to 35%)</span>
</span>
- </p>
- )}
+ </div>
+ </div>
- <div className="isolate grid grid-cols-1 gap-4 overflow-hidden rounded-xl p-4 md:grid-cols-[19fr_21fr]">
- {plansToShow.map((planOption) => {
- const isDataRoomsUpgrade = plansToShow.includes(PlanEnum.DataRooms);
- // Determine which plan to show based on selection for Data Rooms
- let effectivePlan = planOption;
- let displayPlanName = planOption;
-
- const isDataRoomsPlusUpgrade = plansToShow.includes(PlanEnum.DataRooms) && plansToShow.includes(PlanEnum.DataRoomsPlus);
-
- if (planOption === PlanEnum.DataRooms && isDataRoomsUpgrade && !isDataRoomsPlusUpgrade) {
- if (dataRoomsPlanSelection === "plus") {
- effectivePlan = PlanEnum.DataRoomsPlus;
- displayPlanName = PlanEnum.DataRoomsPlus;
- } else if (dataRoomsPlanSelection === "premium") {
- effectivePlan = PlanEnum.DataRoomsPremium;
- displayPlanName = PlanEnum.DataRoomsPremium;
- }
- }
-
- if (planOption === PlanEnum.DataRoomsPlus && isDataRoomsPlusUpgrade) {
- if (dataRoomsPlanSelection === "premium") {
- effectivePlan = PlanEnum.DataRoomsPremium;
- displayPlanName = PlanEnum.DataRoomsPremium;
- }
- }
-
- const highlightForSelector = (() => {
- if (
- plansToShow[0] === PlanEnum.Business &&
- plansToShow[1] === PlanEnum.DataRooms &&
- planOption === PlanEnum.DataRooms
- ) {
- if (trigger === "sidebar_datarooms") {
- if (displayPlanName === PlanEnum.DataRoomsPlus)
- return ["documents"];
- if (displayPlanName === PlanEnum.DataRoomsPremium)
- return ["storage", "file-size"];
- }
- if (trigger === "invite_team_members") {
- if (displayPlanName === PlanEnum.DataRoomsPremium)
- return ["teams", "users"];
- }
- }
- return [];
- })();
-
- const planFeatures = getPlanFeatures(effectivePlan, {
- period,
- highlightFeatures: highlightForSelector,
- });
-
- const isBusinessDataRoomsView =
- plansToShow[0] === PlanEnum.Business &&
- plansToShow[1] === PlanEnum.DataRooms;
-
- const isDataRoomsDataRoomsPlusView =
- plansToShow[0] === PlanEnum.DataRooms &&
- plansToShow[1] === PlanEnum.DataRoomsPlus;
-
- const isRightColumn =
- planOption === plansToShow[1] ||
- (isBusinessDataRoomsView && planOption === PlanEnum.DataRooms);
-
- const getBorderClass = () => {
- if (isBusinessDataRoomsView) {
- if (planOption === PlanEnum.Business)
- return "border-gray-200 dark:border-gray-700";
- if (planOption === PlanEnum.DataRooms) {
- if (displayPlanName === PlanEnum.DataRooms)
- return "border-[#fb7a00]";
- return "border-gray-900 dark:border-white";
+ {/* Scrollable middle — only the plan cards scroll */}
+ <div
+ ref={scrollRefCallback}
+ className="min-h-0 flex-1 overflow-y-auto px-4 sm:px-6"
+ >
+ {trigger === "invite_team_members" &&
+ [
+ PlanEnum.DataRooms,
+ PlanEnum.DataRoomsPlus,
+ PlanEnum.DataRoomsPremium,
+ ].includes(clickedPlan) && (
+ <p
+ className="cursor-pointer pb-4 text-center text-sm text-muted-foreground transition-colors hover:text-foreground"
+ onClick={() => setUnlimitedModalOpen(true)}
+ >
+ Interested in unlimited seats?{" "}
+ <span className="font-light underline underline-offset-4">
+ Get unlimited
+ </span>
+ </p>
+ )}
+
+ {[
+ PlanEnum.DataRooms,
+ PlanEnum.DataRoomsPlus,
+ PlanEnum.DataRoomsPremium,
+ ].includes(clickedPlan) &&
+ trigger !== "invite_team_members" && (
+ <p
+ className="cursor-pointer pb-4 text-center text-sm text-muted-foreground transition-colors hover:text-foreground"
+ onClick={() => setUnlimitedModalOpen(true)}
+ >
+ Deals with everything unlimited?{" "}
+ <span className="font-light underline underline-offset-4">
+ Get unlimited members, storage, and data rooms in one plan.
+ </span>
+ </p>
+ )}
+
+ <div className="isolate grid grid-cols-1 gap-4 rounded-xl md:grid-cols-[19fr_21fr]">
+ {plansToShow.map((planOption) => {
+ const isDataRoomsUpgrade = plansToShow.includes(
+ PlanEnum.DataRooms,
+ );
+ // Determine which plan to show based on selection for Data Rooms
+ let effectivePlan = planOption;
+ let displayPlanName = planOption;
+
+ const isDataRoomsPlusUpgrade =
+ plansToShow.includes(PlanEnum.DataRooms) &&
+ plansToShow.includes(PlanEnum.DataRoomsPlus);
+
+ if (
+ planOption === PlanEnum.DataRooms &&
+ isDataRoomsUpgrade &&
+ !isDataRoomsPlusUpgrade
+ ) {
+ if (dataRoomsPlanSelection === "plus") {
+ effectivePlan = PlanEnum.DataRoomsPlus;
+ displayPlanName = PlanEnum.DataRoomsPlus;
+ } else if (dataRoomsPlanSelection === "premium") {
+ effectivePlan = PlanEnum.DataRoomsPremium;
+ displayPlanName = PlanEnum.DataRoomsPremium;
+ }
}
- }
- if (isDataRoomsDataRoomsPlusView) {
- if (planOption === PlanEnum.DataRooms)
- return "border-[#fb7a00]";
- if (planOption === PlanEnum.DataRoomsPlus) {
- if (displayPlanName === PlanEnum.DataRoomsPremium)
- return "border-gray-900 dark:border-white";
- return "border-gray-200 dark:border-gray-700";
+
+ if (
+ planOption === PlanEnum.DataRoomsPlus &&
+ isDataRoomsPlusUpgrade
+ ) {
+ if (dataRoomsPlanSelection === "premium") {
+ effectivePlan = PlanEnum.DataRoomsPremium;
+ displayPlanName = PlanEnum.DataRoomsPremium;
+ }
}
- }
- if (isRightColumn)
- return "border-gray-900 dark:border-white";
- return "border-gray-200 dark:border-gray-700";
- };
-
- const getBadge = () => {
- if (isBusinessDataRoomsView) {
- if (planOption === PlanEnum.DataRooms && displayPlanName === PlanEnum.DataRooms)
- return { text: "Most popular", className: "bg-[#fb7a00]" };
- if (planOption === PlanEnum.DataRooms && displayPlanName === PlanEnum.DataRoomsPremium)
- return { text: "Best offer", className: "bg-gray-900 dark:bg-white dark:text-gray-900" };
- return null;
- }
- if (isDataRoomsDataRoomsPlusView) {
- if (planOption === PlanEnum.DataRooms)
- return { text: "Most popular", className: "bg-[#fb7a00]" };
- if (planOption === PlanEnum.DataRoomsPlus && displayPlanName === PlanEnum.DataRoomsPremium)
- return { text: "Best offer", className: "bg-gray-900 dark:bg-white dark:text-gray-900" };
- return null;
- }
- if (isRightColumn && displayPlanName === PlanEnum.DataRoomsPremium)
- return { text: "Best offer", className: "bg-gray-900 dark:bg-white dark:text-gray-900" };
- if (planOption === PlanEnum.Business)
- return { text: "Popular", className: "bg-[#fb7a00]" };
- return null;
- };
-
- const badge = getBadge();
-
- return (
- <div
- key={displayPlanName}
- className={cn(
- "relative flex flex-col rounded-lg border bg-white p-6 shadow-sm dark:bg-gray-900",
- getBorderClass(),
- )}
- >
- <div
- className="mb-4 border-b border-gray-200 pb-2 dark:border-gray-700"
- >
- <div className="flex items-center justify-between">
- <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
- {displayPlanName}
- </h3>
- </div>
- {badge && (
- <span
- className={cn(
- "absolute right-2 top-2 rounded px-2 py-1 text-xs text-white",
- badge.className,
- )}
- >
- {badge.text}
- </span>
- )}
- </div>
- <div className="mb-2">
- <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
- €
- {
- PLANS.find((p) => p.name === displayPlanName)?.price[
- period
- ].amount
+ const highlightForSelector = (() => {
+ if (
+ plansToShow[0] === PlanEnum.Business &&
+ plansToShow[1] === PlanEnum.DataRooms &&
+ planOption === PlanEnum.DataRooms
+ ) {
+ if (trigger === "sidebar_datarooms") {
+ if (displayPlanName === PlanEnum.DataRoomsPlus)
+ return ["documents"];
+ if (displayPlanName === PlanEnum.DataRoomsPremium)
+ return ["storage", "file-size"];
}
- </span>
- <span
- className="text-gray-500 dark:text-white/75"
+ if (trigger === "invite_team_members") {
+ if (displayPlanName === PlanEnum.DataRoomsPremium)
+ return ["teams", "users"];
+ }
+ }
+ return [];
+ })();
+
+ const planFeatures = getPlanFeatures(effectivePlan, {
+ period,
+ highlightFeatures: highlightForSelector,
+ });
+
+ const isBusinessDataRoomsView =
+ plansToShow[0] === PlanEnum.Business &&
+ plansToShow[1] === PlanEnum.DataRooms;
+
+ const isDataRoomsDataRoomsPlusView =
+ plansToShow[0] === PlanEnum.DataRooms &&
+ plansToShow[1] === PlanEnum.DataRoomsPlus;
+
+ const isRightColumn =
+ planOption === plansToShow[1] ||
+ (isBusinessDataRoomsView &&
+ planOption === PlanEnum.DataRooms);
+
+ const getBorderClass = () => {
+ if (isBusinessDataRoomsView) {
+ if (planOption === PlanEnum.Business)
+ return "border-gray-200 dark:border-gray-700";
+ if (planOption === PlanEnum.DataRooms) {
+ if (displayPlanName === PlanEnum.DataRooms)
+ return "border-[#fb7a00]";
+ return "border-gray-900 dark:border-white";
+ }
+ }
+ if (isDataRoomsDataRoomsPlusView) {
+ if (planOption === PlanEnum.DataRooms)
+ return "border-[#fb7a00]";
+ if (planOption === PlanEnum.DataRoomsPlus) {
+ if (displayPlanName === PlanEnum.DataRoomsPremium)
+ return "border-gray-900 dark:border-white";
+ return "border-gray-200 dark:border-gray-700";
+ }
+ }
+ if (isRightColumn) return "border-gray-900 dark:border-white";
+ return "border-gray-200 dark:border-gray-700";
+ };
+
+ const getBadge = () => {
+ if (isBusinessDataRoomsView) {
+ if (
+ planOption === PlanEnum.DataRooms &&
+ displayPlanName === PlanEnum.DataRooms
+ )
+ return {
+ text: "Most popular",
+ className: "bg-[#fb7a00]",
+ };
+ if (
+ planOption === PlanEnum.DataRooms &&
+ displayPlanName === PlanEnum.DataRoomsPremium
+ )
+ return {
+ text: "Best offer",
+ className:
+ "bg-gray-900 dark:bg-white dark:text-gray-900",
+ };
+ return null;
+ }
+ if (isDataRoomsDataRoomsPlusView) {
+ if (planOption === PlanEnum.DataRooms)
+ return {
+ text: "Most popular",
+ className: "bg-[#fb7a00]",
+ };
+ if (
+ planOption === PlanEnum.DataRoomsPlus &&
+ displayPlanName === PlanEnum.DataRoomsPremium
+ )
+ return {
+ text: "Best offer",
+ className:
+ "bg-gray-900 dark:bg-white dark:text-gray-900",
+ };
+ return null;
+ }
+ if (
+ isRightColumn &&
+ displayPlanName === PlanEnum.DataRoomsPremium
+ )
+ return {
+ text: "Best offer",
+ className: "bg-gray-900 dark:bg-white dark:text-gray-900",
+ };
+ if (planOption === PlanEnum.Business)
+ return { text: "Popular", className: "bg-[#fb7a00]" };
+ return null;
+ };
+
+ const badge = getBadge();
+
+ return (
+ <div
+ key={displayPlanName}
+ className={cn(
+ "relative flex flex-col rounded-lg border bg-white p-6 shadow-sm dark:bg-gray-900",
+ getBorderClass(),
+ )}
>
- /month{period === "yearly" && ", billed annually"}
- </span>
- </div>
+ <div className="mb-4 border-b border-gray-200 pb-2 dark:border-gray-700">
+ <div className="flex items-center justify-between">
+ <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
+ {displayPlanName}
+ </h3>
+ </div>
+ {badge && (
+ <span
+ className={cn(
+ "absolute right-2 top-2 rounded px-2 py-1 text-xs text-white",
+ badge.className,
+ )}
+ >
+ {badge.text}
+ </span>
+ )}
+ </div>
- {planOption === PlanEnum.DataRooms &&
- isDataRoomsUpgrade &&
- !plansToShow.includes(PlanEnum.DataRoomsPlus) && (
- <PlanSelector
- value={dataRoomsPlanSelection}
- onChange={setDataRoomsPlanSelection}
- />
- )}
- {planOption === PlanEnum.DataRoomsPlus &&
- isDataRoomsPlusUpgrade && (
- <div className="mt-1 flex w-full rounded-lg border border-gray-200 p-1">
- <button
- className={cn(
- "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
- dataRoomsPlanSelection !== "premium"
- ? "bg-gray-800 text-white dark:bg-gray-200 dark:text-gray-900"
- : "text-gray-600 hover:text-gray-900 dark:text-muted-foreground dark:hover:text-white",
- )}
- onClick={() => setDataRoomsPlanSelection("plus")}
- >
- Plus
- </button>
- <button
- className={cn(
- "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
- dataRoomsPlanSelection === "premium"
- ? "bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900"
- : "text-gray-600 hover:text-gray-900 dark:text-muted-foreground dark:hover:text-white",
- )}
- onClick={() => setDataRoomsPlanSelection("premium")}
- >
- Premium
- </button>
+ <div className="mb-2">
+ <span className="text-balance text-4xl font-medium tabular-nums text-gray-900 dark:text-white">
+ €
+ {
+ PLANS.find((p) => p.name === displayPlanName)?.price[
+ period
+ ].amount
+ }
+ </span>
+ <span className="text-gray-500 dark:text-white/75">
+ /month{period === "yearly" && ", billed annually"}
+ </span>
</div>
- )}
- <p className="mt-4 text-sm text-gray-600 dark:text-white">
- {planFeatures.featureIntro}
- </p>
+ {planOption === PlanEnum.DataRooms &&
+ isDataRoomsUpgrade &&
+ !plansToShow.includes(PlanEnum.DataRoomsPlus) && (
+ <PlanSelector
+ value={dataRoomsPlanSelection}
+ onChange={setDataRoomsPlanSelection}
+ />
+ )}
+ {planOption === PlanEnum.DataRoomsPlus &&
+ isDataRoomsPlusUpgrade && (
+ <div className="mt-1 flex w-full rounded-lg border border-gray-200 p-1">
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ dataRoomsPlanSelection !== "premium"
+ ? "bg-gray-800 text-white dark:bg-gray-200 dark:text-gray-900"
+ : "text-gray-600 hover:text-gray-900 dark:text-muted-foreground dark:hover:text-white",
+ )}
+ onClick={() => setDataRoomsPlanSelection("plus")}
+ >
+ Plus
+ </button>
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ dataRoomsPlanSelection === "premium"
+ ? "bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900"
+ : "text-gray-600 hover:text-gray-900 dark:text-muted-foreground dark:hover:text-white",
+ )}
+ onClick={() => setDataRoomsPlanSelection("premium")}
+ >
+ Premium
+ </button>
+ </div>
+ )}
- <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-gray-300">
- {planFeatures.features
- .filter((feature) => {
- if (!hideItems?.length) return true;
- if (hideItems.includes(feature.id)) return false;
- if (
- feature.aliasIds?.some((alias) =>
- hideItems.includes(alias),
- )
- ) {
- return false;
- }
- return true;
- })
- .map((feature, i) => {
- const isDataRoomPlan =
- effectivePlan === PlanEnum.DataRooms ||
- effectivePlan === PlanEnum.DataRoomsPlus ||
- effectivePlan === PlanEnum.DataRoomsPremium;
- return (
- <li key={i}>
- <FeatureItem
- feature={{
- ...feature,
- isHighlighted:
- feature.isHighlighted ||
- highlightItem?.includes(feature.id) ||
+ <p className="mt-4 text-sm text-gray-600 dark:text-white">
+ {planFeatures.featureIntro}
+ </p>
+
+ <ul className="mb-2 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-gray-300">
+ {planFeatures.features
+ .filter((feature) => {
+ // Hide the generic "Unlimited data rooms" line on the
+ // higher data room tiers (Plus/Premium/Unlimited) — the
+ // base Data Rooms card already communicates it. Keep it
+ // for data-room popups (data rooms tab / trial) and for
+ // generic Plus/Premium-only comparisons, but not for
+ // feature-specific upsells (e.g. API, SSO).
+ const isHigherDataRoomTier =
+ effectivePlan === PlanEnum.DataRoomsPlus ||
+ effectivePlan === PlanEnum.DataRoomsPremium ||
+ effectivePlan === PlanEnum.DataRoomsUnlimited;
+ const showUnlimitedDataRoomsLine =
+ isDataRoomContextPopup ||
+ (onlyPlusAndPremiumShown &&
+ !hasSpecificFeatureHighlight);
+ if (
+ feature.id === "datarooms" &&
+ isHigherDataRoomTier &&
+ !showUnlimitedDataRoomsLine
+ ) {
+ return false;
+ }
+ // "Assign team members" is only shown (and highlighted)
+ // when the upsell originates from the assign-team-members
+ // flow; otherwise keep it off every plan card.
+ if (
+ feature.id === "assign" &&
+ !(
+ highlightItem?.includes("assign") ||
feature.aliasIds?.some((alias) =>
highlightItem?.includes(alias),
- ),
- }}
- onUnlimitedClick={
- feature.isUsers && isDataRoomPlan
- ? () => setUnlimitedModalOpen(true)
- : undefined
+ )
+ )
+ ) {
+ return false;
}
- />
- </li>
- );
- })}
- </ul>
-
- <div className="mt-auto">
- <Button
- variant={
- planOption === PlanEnum.Business && !isBusinessDataRoomsView
- ? "default"
- : "outline"
- }
- className={cn("w-full py-2 text-sm", (() => {
- if (isBusinessDataRoomsView && planOption === PlanEnum.DataRooms && displayPlanName === PlanEnum.DataRooms)
- return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
- if (isDataRoomsDataRoomsPlusView && planOption === PlanEnum.DataRooms)
- return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
- if (planOption === PlanEnum.Business && !isBusinessDataRoomsView)
- return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
- return "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200";
- })())}
- loading={selectedPlan === planOption}
- disabled={selectedPlan !== null}
- onClick={() => {
- const priceId = getPriceIdFromPlan({
- planName: displayPlanName,
- period,
- isOld: isOldAccount,
- });
-
- setSelectedPlan(planOption);
- if (isCustomer && teamPlan !== "free") {
- fetch(`/api/teams/${teamId}/billing/manage`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- priceId,
- upgradePlan: true,
- }),
+ if (!hideItems?.length) return true;
+ if (hideItems.includes(feature.id)) return false;
+ if (
+ feature.aliasIds?.some((alias) =>
+ hideItems.includes(alias),
+ )
+ ) {
+ return false;
+ }
+ return true;
})
- .then(async (res) => {
- const url = await res.json();
- router.push(url);
- })
- .catch((err) => {
- alert(err);
- setSelectedPlan(null);
- });
- } else {
- fetch(
- `/api/teams/${teamId}/billing/upgrade?priceId=${
- priceId
- }`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- },
- )
- .then(async (res) => {
- const data = await res.json();
- const { id: sessionId } = data;
- const stripe = await getStripe(isOldAccount);
- stripe?.redirectToCheckout({ sessionId });
- })
- .catch((err) => {
- alert(err);
- setSelectedPlan(null);
+ .map((feature, i) => {
+ const isDataRoomPlan =
+ effectivePlan === PlanEnum.DataRooms ||
+ effectivePlan === PlanEnum.DataRoomsPlus ||
+ effectivePlan === PlanEnum.DataRoomsPremium;
+ return (
+ <li key={i}>
+ <FeatureItem
+ feature={{
+ ...feature,
+ isHighlighted:
+ feature.isHighlighted ||
+ highlightItem?.includes(feature.id) ||
+ feature.aliasIds?.some((alias) =>
+ highlightItem?.includes(alias),
+ ),
+ }}
+ onUnlimitedClick={
+ feature.isUsers && isDataRoomPlan
+ ? () => setUnlimitedModalOpen(true)
+ : undefined
+ }
+ />
+ </li>
+ );
+ })}
+ </ul>
+
+ <div className="sticky bottom-0 z-10 -mx-6 -mb-6 mt-auto rounded-b-lg bg-white px-6 pb-6 pt-2 dark:bg-gray-900">
+ <Button
+ variant={
+ planOption === PlanEnum.Business &&
+ !isBusinessDataRoomsView
+ ? "default"
+ : "outline"
+ }
+ className={cn(
+ "w-full py-2 text-sm",
+ (() => {
+ if (
+ isBusinessDataRoomsView &&
+ planOption === PlanEnum.DataRooms &&
+ displayPlanName === PlanEnum.DataRooms
+ )
+ return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
+ if (
+ isDataRoomsDataRoomsPlusView &&
+ planOption === PlanEnum.DataRooms
+ )
+ return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
+ if (
+ planOption === PlanEnum.Business &&
+ !isBusinessDataRoomsView
+ )
+ return "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00] hover:text-white";
+ return "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200";
+ })(),
+ )}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ const priceId = getPriceIdFromPlan({
+ planName: displayPlanName,
+ period,
+ isOld: isOldAccount,
});
- }
- }}
- >
- {selectedPlan === planOption
- ? "Redirecting to Stripe..."
- : `Upgrade to ${displayPlanName} ${capitalize(period)}`}
- </Button>
- </div>
- </div>
- );
- })}
- </div>
- <div className="text-center text-sm text-muted-foreground">
- All plans include unlimited visitors and page by page document
- analytics.{" "}
- <Link
- href={`/settings/upgrade${
- clickedPlan === PlanEnum.Pro
- ? "?view=documents"
- : clickedPlan === PlanEnum.Business
- ? "?view=business-datarooms"
- : ""
- }`}
- className="underline underline-offset-4 hover:text-foreground"
- >
- See all plans
- </Link>
- {((teamPlan === "free" && !isTrial) ||
- (teamPlan === "pro" && !isTrial)) && (
- <>
- {" | "}
- <StartDataRoomTrialButton teamId={teamId} />
- </>
- )}
- </div>
- <UnlimitedPlanModal
- period={period}
- open={unlimitedModalOpen}
- setOpen={setUnlimitedModalOpen}
- />
+ setSelectedPlan(planOption);
+ if (isCustomer && teamPlan !== "free") {
+ fetch(`/api/teams/${teamId}/billing/manage`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ priceId,
+ upgradePlan: true,
+ }),
+ })
+ .then(async (res) => {
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ } else {
+ fetch(
+ `/api/teams/${teamId}/billing/upgrade?priceId=${
+ priceId
+ }`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ )
+ .then(async (res) => {
+ const data = await res.json();
+ const { id: sessionId } = data;
+ const stripe = await getStripe(isOldAccount);
+ stripe?.redirectToCheckout({ sessionId });
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ }
+ }}
+ >
+ {selectedPlan === planOption
+ ? "Redirecting to Stripe..."
+ : `Upgrade to ${displayPlanName} ${capitalize(period)}`}
+ </Button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ {/* Fixed footer — actions and trial stay visible without scrolling */}
+ <div
+ className={cn(
+ "flex-none bg-gray-50 px-4 pb-5 pt-4 text-center text-sm text-muted-foreground dark:bg-gray-900 sm:px-6",
+ isScrollable && "border-t border-gray-200 dark:border-gray-800",
+ )}
+ >
+ All plans include{" "}
+ <span className="font-medium text-foreground">
+ unlimited visitors
+ </span>{" "}
+ and page by page document analytics.{" "}
+ <Link
+ href={`/settings/upgrade${
+ clickedPlan === PlanEnum.Pro
+ ? "?view=documents"
+ : clickedPlan === PlanEnum.Business
+ ? "?view=business-datarooms"
+ : ""
+ }`}
+ className="underline underline-offset-4 hover:text-foreground"
+ >
+ See all plans
+ </Link>
+ {((teamPlan === "free" && !isTrial) ||
+ (teamPlan === "pro" && !isTrial)) && (
+ <>
+ {" | "}
+ <StartDataRoomTrialButton teamId={teamId} />
+ </>
+ )}
+ </div>
+
+ <UnlimitedPlanModal
+ period={period}
+ open={unlimitedModalOpen}
+ setOpen={setUnlimitedModalOpen}
+ />
</div>
</DialogContent>
</Dialog>
diff --git a/components/datarooms/dataroom-trial-modal.tsx b/components/datarooms/dataroom-trial-modal.tsx
index 6dab4c7a..8c2c66d1 100644
--- a/components/datarooms/dataroom-trial-modal.tsx
+++ b/components/datarooms/dataroom-trial-modal.tsx
@@ -265,7 +265,7 @@ export function DataroomTrialModal({
<UpgradePlanModal clickedPlan={PlanEnum.Business}>
<button className="underline">Papermark Business</button>
</UpgradePlanModal>{" "}
- to continue using Data Room plan features.
+ to continue using advanced data room features.
</div>
</div>
</DialogFooter>
diff --git a/components/datarooms/settings/dataroom-team-members.tsx b/components/datarooms/settings/dataroom-team-members.tsx
new file mode 100644
index 00000000..a8333af1
--- /dev/null
+++ b/components/datarooms/settings/dataroom-team-members.tsx
@@ -0,0 +1,440 @@
+import { useState } from "react";
+
+import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
+import {
+ CircleHelpIcon,
+ MoreHorizontalIcon,
+ UserMinusIcon,
+ XCircleIcon,
+} from "lucide-react";
+import { useSession } from "next-auth/react";
+import { toast } from "sonner";
+import { mutate } from "swr";
+
+import { useSelfMembership } from "@/lib/hooks/use-self-membership";
+import { usePlan } from "@/lib/swr/use-billing";
+import { useDataroomMembers } from "@/lib/swr/use-dataroom-members";
+import useLimits from "@/lib/swr/use-limits";
+import { CustomUser, TeamRole } from "@/lib/types";
+import { generateGravatarHash } from "@/lib/utils";
+
+import { AddSeatModal } from "@/components/billing/add-seat-modal";
+import { AddTeamMembers } from "@/components/teams/add-team-member-modal";
+import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
+import { BadgeTooltip } from "@/components/ui/tooltip";
+import { UpgradeButton } from "@/components/ui/upgrade-button";
+
+const ROLE_LABELS: Record<TeamRole, string> = {
+ ADMIN: "Admin",
+ MANAGER: "Manager",
+ MEMBER: "Member",
+ DATAROOM_MEMBER: "Data room member",
+};
+
+export default function DataroomTeamMembers({
+ dataroomId,
+ dataroomName,
+}: {
+ dataroomId: string;
+ dataroomName?: string;
+}) {
+ const { currentTeamId } = useTeam();
+ const {
+ members,
+ invitations,
+ loading,
+ mutate: mutateMembers,
+ } = useDataroomMembers(dataroomId);
+ const { data: session } = useSession();
+ const { role } = useSelfMembership();
+ const { isDataroomsUnlimited } = usePlan();
+ const { canAddUsers, showUpgradePlanModal, limits } = useLimits();
+ const canManage = role === "ADMIN" || role === "MANAGER";
+ // Inviting goes through the team invite endpoint, which is admin-only.
+ const canInvite = role === "ADMIN";
+ const seatsUnlimited =
+ isDataroomsUnlimited ||
+ limits?.users === null ||
+ limits?.users === Infinity;
+
+ const currentUserId = (session?.user as CustomUser)?.id;
+
+ const [removingId, setRemovingId] = useState<string>("");
+ const [isInviteOpen, setIsInviteOpen] = useState(false);
+ const [isAddSeatOpen, setIsAddSeatOpen] = useState(false);
+
+ const removeMember = async (userId: string) => {
+ setRemovingId(userId);
+ try {
+ const response = await fetch(
+ `/api/teams/${currentTeamId}/datarooms/${dataroomId}/members`,
+ {
+ method: "DELETE",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ userId }),
+ },
+ );
+ if (response.status !== 204) {
+ const { error } = await response.json();
+ toast.error(error || "Could not remove member.");
+ return;
+ }
+ await mutateMembers();
+ toast.success("Member removed from data room.");
+ } catch (error) {
+ toast.error("Could not remove member.");
+ } finally {
+ setRemovingId("");
+ }
+ };
+
+ const revokeInvitation = async (email: string) => {
+ setRemovingId(email);
+ try {
+ const response = await fetch(
+ `/api/teams/${currentTeamId}/datarooms/${dataroomId}/members`,
+ {
+ method: "DELETE",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ email }),
+ },
+ );
+ if (response.status !== 204) {
+ const { error } = await response.json();
+ toast.error(error || "Could not revoke invitation.");
+ return;
+ }
+ await mutateMembers();
+ mutate(`/api/teams/${currentTeamId}/invitations`);
+ toast.success("Invitation revoked.");
+ } catch (error) {
+ toast.error("Could not revoke invitation.");
+ } finally {
+ setRemovingId("");
+ }
+ };
+
+ const isEmpty =
+ !loading && members.length === 0 && invitations.length === 0;
+
+ return (
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ {dataroomName ? `${dataroomName} members` : "Members"}
+ </h2>
+ <BadgeTooltip
+ content="Teammates that have access to this data room."
+ className="max-w-80 text-left leading-5 text-gray-600"
+ >
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
+ </BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ People on your team with access to this data room.
+ {!seatsUnlimited && limits?.users ? (
+ <span className="ml-1">
+ {limits.usage?.users ?? 0}/{limits.users} seats used.
+ </span>
+ ) : null}
+ </p>
+ </div>
+ {canInvite ? (
+ showUpgradePlanModal ? (
+ <UpgradeButton
+ text="Business"
+ clickedPlan={PlanEnum.Business}
+ trigger="dataroom_add_member"
+ highlightItem={["users", "assign"]}
+ />
+ ) : (
+ <div className="flex items-center gap-2">
+ {!seatsUnlimited ? (
+ <AddSeatModal open={isAddSeatOpen} setOpen={setIsAddSeatOpen}>
+ <Button variant="outline" className="whitespace-nowrap">
+ Add Seat
+ </Button>
+ </AddSeatModal>
+ ) : null}
+ {canAddUsers ? (
+ <AddTeamMembers
+ open={isInviteOpen}
+ setOpen={setIsInviteOpen}
+ defaultRole="DATAROOM_MEMBER"
+ defaultDataroomIds={[dataroomId]}
+ currentDataroomId={dataroomId}
+ redirectToPeople={false}
+ onInvited={() => mutateMembers()}
+ >
+ <Button className="whitespace-nowrap bg-gray-900 text-gray-50 hover:bg-gray-900/90">
+ Add team member
+ </Button>
+ </AddTeamMembers>
+ ) : (
+ <Button disabled title="Add a seat to invite more members">
+ Add team member
+ </Button>
+ )}
+ </div>
+ )
+ ) : null}
+ </div>
+
+ {loading ? (
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
+ </div>
+ ) : isEmpty ? (
+ <div className="px-6 py-10 text-center text-sm text-gray-500 dark:text-gray-400">
+ No team members have access to this data room yet.
+ </div>
+ ) : (
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Member
+ </TableHead>
+ <TableHead className="text-right text-xs font-medium tracking-wide text-gray-500">
+ Role
+ </TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {members.map((member) => {
+ const isSelf = member.userId === currentUserId;
+ return (
+ <TableRow
+ key={member.userId}
+ className="hover:bg-transparent"
+ >
+ <TableCell>
+ <div className="flex items-center gap-3">
+ <PersonAvatar
+ email={member.email}
+ name={member.name}
+ />
+ <div className="flex flex-col">
+ <span className="flex items-center gap-2 font-medium text-gray-900 dark:text-gray-100">
+ {member.name || member.email}
+ {isSelf ? (
+ <span className="rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400">
+ You
+ </span>
+ ) : null}
+ </span>
+ <span className="text-xs text-gray-500">
+ {member.email}
+ </span>
+ </div>
+ </div>
+ </TableCell>
+ <TableCell className="text-right text-sm text-gray-700 dark:text-gray-300">
+ <div className="flex flex-col items-end gap-1">
+ <span>{ROLE_LABELS[member.role]}</span>
+ {member.status === "BLOCKED_TRIAL_EXPIRED" ? (
+ <span className="text-xs font-medium text-red-500">
+ Blocked (Trial Expired)
+ </span>
+ ) : (
+ <span className="inline-flex items-center gap-1.5 text-xs text-gray-500">
+ <span className="h-1.5 w-1.5 rounded-full bg-green-500" />
+ Active
+ </span>
+ )}
+ </div>
+ </TableCell>
+ <TableCell className="text-right">
+ {/* Only scoped members can be removed from a single room;
+ full members have team-wide access. */}
+ {canManage && member.scoped ? (
+ removingId === member.userId ? (
+ <span className="text-xs text-gray-500">
+ removing...
+ </span>
+ ) : (
+ <MemberRowMenu
+ onRemove={() => removeMember(member.userId)}
+ />
+ )
+ ) : (
+ <div className="ml-auto h-8 w-8" />
+ )}
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ {invitations.map((invitation) => {
+ const isPending =
+ new Date(invitation.expires) >= new Date();
+ return (
+ <TableRow
+ key={invitation.email}
+ className="hover:bg-transparent"
+ >
+ <TableCell>
+ <div className="flex items-center gap-3">
+ <PersonAvatar email={invitation.email} />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {invitation.email}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-right text-sm text-gray-700 dark:text-gray-300">
+ <div className="flex flex-col items-end gap-1">
+ <span className="text-gray-500">Invited</span>
+ <span
+ className="text-xs text-gray-500"
+ title={`Expires on ${new Date(
+ invitation.expires,
+ ).toLocaleString()}`}
+ >
+ {isPending ? "Pending" : "Expired"}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-right">
+ {canManage ? (
+ removingId === invitation.email ? (
+ <span className="text-xs text-gray-500">
+ removing...
+ </span>
+ ) : (
+ <InvitationRowMenu
+ onRevoke={() => revokeInvitation(invitation.email)}
+ />
+ )
+ ) : (
+ <div className="ml-auto h-8 w-8" />
+ )}
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ </div>
+ )}
+ </div>
+ );
+}
+
+function PersonAvatar({
+ email,
+ name,
+}: {
+ email: string;
+ name?: string | null;
+}) {
+ const label = (name || email || "").trim();
+ return (
+ <Avatar className="h-8 w-8 shrink-0 border border-gray-200 dark:border-gray-800">
+ <AvatarImage
+ src={`https://gravatar.com/avatar/${generateGravatarHash(
+ email,
+ )}?s=80&d=404`}
+ alt={label}
+ />
+ <AvatarFallback className="bg-gray-100 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-300">
+ {label.charAt(0).toUpperCase()}
+ </AvatarFallback>
+ </Avatar>
+ );
+}
+
+function MemberRowMenu({ onRemove }: { onRemove: () => void }) {
+ const [open, setOpen] = useState(false);
+
+ const handleSelect = (event: Event, action: () => void) => {
+ event.preventDefault();
+ setOpen(false);
+ action();
+ };
+
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="ml-auto h-8 w-8"
+ aria-label="Open member actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onRemove)}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <UserMinusIcon className="!h-4 !w-4" />
+ Remove access
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+function InvitationRowMenu({ onRevoke }: { onRevoke: () => void }) {
+ const [open, setOpen] = useState(false);
+
+ const handleSelect = (event: Event, action: () => void) => {
+ event.preventDefault();
+ setOpen(false);
+ action();
+ };
+
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="ml-auto h-8 w-8"
+ aria-label="Open invitation actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onRevoke)}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <XCircleIcon className="!h-4 !w-4" />
+ Revoke invitation
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/components/domains/add-domain-modal.tsx b/components/domains/add-domain-modal.tsx
index 9d9f7c9b..9a417159 100644
--- a/components/domains/add-domain-modal.tsx
+++ b/components/domains/add-domain-modal.tsx
@@ -2,7 +2,7 @@ import { type ElementType, useEffect, useRef, useState } from "react";
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
-import { LinkType } from "@prisma/client";
+import { Domain, LinkType } from "@prisma/client";
import { AlertTriangleIcon, CircleCheckIcon, InfoIcon } from "lucide-react";
import { toast } from "sonner";
import { useDebounce } from "use-debounce";
@@ -99,7 +99,7 @@ export function AddDomainModal({
}: {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
- onAddition?: (newDomain: string) => void;
+ onAddition?: (newDomain: Domain) => void;
linkType?: Omit<LinkType, "WORKFLOW_LINK">;
children?: React.ReactNode;
}) {
diff --git a/components/domains/domain-card.tsx b/components/domains/domain-card.tsx
deleted file mode 100644
index 56525095..00000000
--- a/components/domains/domain-card.tsx
+++ /dev/null
@@ -1,316 +0,0 @@
-import { useRef, useState } from "react";
-
-import { useTeam } from "@/context/team-context";
-import {
- ChevronDownIcon,
- CircleCheckIcon,
- ExternalLinkIcon,
- FlagIcon,
- GlobeIcon,
- MoreVertical,
- RefreshCwIcon,
- SettingsIcon,
- TrashIcon,
-} from "lucide-react";
-import { motion } from "motion/react";
-import { toast } from "sonner";
-import { mutate } from "swr";
-
-import { cn } from "@/lib/utils";
-
-import { Button } from "@/components/ui/button";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { Input } from "@/components/ui/input";
-import { StatusBadge } from "@/components/ui/status-badge";
-
-import { useDeleteDomainModal } from "./delete-domain-modal";
-import DomainConfiguration from "./domain-configuration";
-import { useDomainStatus } from "./use-domain-status";
-
-export default function DomainCard({
- domain,
- isDefault,
- redirectUrl: initialRedirectUrl,
- redirectsAllowed,
- onDelete,
-}: {
- domain: string;
- isDefault: boolean;
- redirectUrl?: string | null;
- redirectsAllowed: boolean;
- onDelete: (deletedDomain: string) => void;
-}) {
- const [showDetails, setShowDetails] = useState(false);
- const [groupHover, setGroupHover] = useState(false);
- const [menuOpen, setMenuOpen] = useState(false);
- const [redirectUrl, setRedirectUrl] = useState(initialRedirectUrl || "");
- const [savingRedirect, setSavingRedirect] = useState(false);
-
- const domainRef = useRef<HTMLDivElement>(null);
-
- const {
- status,
- loading,
- domainJson,
- configJson,
- mutate: mutateDomain,
- } = useDomainStatus({
- domain,
- });
- const teamInfo = useTeam();
- const teamId = teamInfo?.currentTeam?.id;
-
- const isInvalid =
- status && !["Valid Configuration", "Pending Verification"].includes(status);
-
- const { setShowDeleteDomainModal, DeleteDomainModal } = useDeleteDomainModal({
- domain,
- onDelete,
- });
-
- const handleSaveRedirectUrl = async () => {
- setSavingRedirect(true);
- try {
- const response = await fetch(`/api/teams/${teamId}/domains/${domain}`, {
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ redirectUrl: redirectUrl || null }),
- });
-
- if (!response.ok) {
- const data = await response.json();
- toast.error(data?.message || "Failed to save redirect URL");
- return;
- }
-
- mutate(`/api/teams/${teamId}/domains`);
- toast.success(
- redirectUrl
- ? "Root redirect URL saved"
- : "Root redirect URL removed",
- );
- } catch {
- toast.error("Failed to save redirect URL");
- } finally {
- setSavingRedirect(false);
- }
- };
-
- const handleMakeDefault = async () => {
- const response = await fetch(`/api/teams/${teamId}/domains/${domain}`, {
- method: "PATCH",
- });
-
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
-
- // Update domains by refetching
- mutate(`/api/teams/${teamId}/domains`);
- };
-
- return (
- <>
- <div
- ref={domainRef}
- className="group rounded-xl border border-gray-200 bg-white p-4 transition-[filter] dark:border-gray-400 dark:bg-secondary sm:p-5"
- onPointerEnter={() => setGroupHover(true)}
- onPointerLeave={() => setGroupHover(false)}
- >
- <div className="flex items-center justify-between gap-3 sm:gap-4">
- <div className="flex min-w-0 items-center gap-4">
- <div className="hidden rounded-full border border-gray-200 dark:border-gray-400 sm:block">
- <div
- className={cn(
- "rounded-full",
- "border border-white bg-gradient-to-t from-gray-100 p-1 md:p-3",
- )}
- >
- <GlobeIcon className="size-5" />
- </div>
- </div>
- <div className="overflow-hidden">
- <div className="flex items-center gap-1.5 truncate text-sm font-medium sm:gap-2.5">
- {domain}
-
- {isDefault ? (
- <span className="xs:px-3 xs:py-1 flex items-center gap-1 rounded-full bg-sky-400/[.15] px-1.5 py-0.5 text-xs font-medium text-sky-600">
- <FlagIcon className="hidden h-3 w-3 sm:block" />
- Default
- </span>
- ) : null}
- </div>
- </div>
- </div>
-
- <div className="flex items-center justify-end gap-2 sm:gap-3">
- {/* Status */}
- <div className="hidden sm:block">
- {status && !loading ? (
- <StatusBadge
- variant={
- status === "Valid Configuration"
- ? "success"
- : status === "Pending Verification"
- ? "pending"
- : "error"
- }
- >
- {status === "Valid Configuration"
- ? "Active"
- : status === "Pending Verification"
- ? "Pending"
- : "Invalid"}
- </StatusBadge>
- ) : (
- <div className="h-6 w-16 animate-pulse rounded-md bg-gray-200 dark:bg-gray-400" />
- )}
- </div>
- <Button
- variant="secondary"
- className={cn(
- "h-8 w-auto px-2 opacity-100 transition-opacity lg:h-9",
- !showDetails &&
- !isInvalid &&
- "sm:opacity-0 sm:group-hover:opacity-100",
- )}
- onClick={() => setShowDetails((s) => !s)}
- data-state={showDetails ? "open" : "closed"}
- >
- <div className="flex items-center gap-1">
- <div className="relative">
- <SettingsIcon
- className={cn(
- "h-4 w-4",
- showDetails
- ? "text-gray-800 dark:text-gray-200"
- : "text-gray-600 dark:text-gray-400",
- )}
- />
- {/* Error indicator */}
- {status && isInvalid && (
- <div className="absolute -right-px -top-px h-[5px] w-[5px] rounded-full bg-destructive">
- <div className="h-full w-full animate-pulse rounded-full ring-2 ring-destructive/30" />
- </div>
- )}
- </div>
- <ChevronDownIcon
- className={cn(
- "hidden h-4 w-4 text-gray-400 transition-transform sm:block",
- showDetails && "rotate-180",
- )}
- />
- </div>
- </Button>
- <DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>
- <DropdownMenuTrigger asChild>
- <Button
- // size="icon"
- variant="outline"
- className="z-20 h-8 w-8 border-gray-200 bg-transparent p-0 hover:bg-gray-200 dark:border-gray-400 hover:dark:border-gray-400 hover:dark:bg-gray-700 lg:h-9 lg:w-9"
- >
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem
- disabled={isDefault}
- onClick={handleMakeDefault}
- >
- <FlagIcon className="mr-2 h-4 w-4" />
- Make default
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => mutateDomain()}
- disabled={loading}
- >
- <RefreshCwIcon className="mr-2 h-4 w-4" />
- Refresh
- </DropdownMenuItem>
- <DropdownMenuItem
- className="text-destructive transition-colors duration-200 focus:bg-destructive focus:text-destructive-foreground"
- onClick={() => setShowDeleteDomainModal(true)}
- >
- <TrashIcon className="mr-2 h-4 w-4" />
- Delete domain
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </div>
- <motion.div
- initial={false}
- animate={{ height: showDetails ? "auto" : 0 }}
- className="overflow-hidden"
- >
- {status ? (
- status === "Valid Configuration" ? (
- <div className="mt-6 flex items-center gap-2 text-pretty rounded-lg bg-green-100/80 p-3 text-sm text-green-600">
- <CircleCheckIcon className="h-5 w-5 shrink-0" />
- <div>
- Good news! Your DNS records are set up correctly, but it can
- take some time for them to propagate globally.
- </div>
- </div>
- ) : (
- <DomainConfiguration
- status={status}
- response={{ domainJson, configJson }}
- />
- )
- ) : (
- <div className="mt-6 h-6 w-32 animate-pulse rounded-md bg-gray-200 dark:bg-gray-400" />
- )}
-
- {/* Root domain redirect */}
- <div className="mt-4 rounded-lg border border-gray-200 p-4 dark:border-gray-400">
- <div className="flex items-center gap-2 text-sm font-medium text-foreground">
- <ExternalLinkIcon className="h-4 w-4" />
- Root Domain Redirect
- </div>
- {redirectsAllowed ? (
- <>
- <p className="mt-1 text-xs text-muted-foreground">
- Redirect visitors who land on{" "}
- <span className="font-medium">{domain}</span> to a specific
- URL. Leave empty to redirect to papermark.com.
- </p>
- <div className="mt-3 flex items-center gap-2">
- <Input
- type="url"
- placeholder="https://example.com"
- value={redirectUrl}
- onChange={(e) => setRedirectUrl(e.target.value)}
- className="h-9 flex-1"
- />
- <Button
- size="sm"
- onClick={handleSaveRedirectUrl}
- disabled={savingRedirect}
- className="h-9 shrink-0"
- >
- {savingRedirect ? "Saving..." : "Save"}
- </Button>
- </div>
- </>
- ) : (
- <p className="mt-1 text-xs text-muted-foreground">
- Root domain redirects require a{" "}
- <span className="font-semibold">Business</span> plan or higher.
- </p>
- )}
- </div>
- </motion.div>
- </div>
- <DeleteDomainModal />
- </>
- );
-}
diff --git a/components/domains/domain-row.tsx b/components/domains/domain-row.tsx
new file mode 100644
index 00000000..070a7e7b
--- /dev/null
+++ b/components/domains/domain-row.tsx
@@ -0,0 +1,302 @@
+import { useEffect, useState } from "react";
+
+import { useTeam } from "@/context/team-context";
+import {
+ CircleCheckIcon,
+ ExternalLinkIcon,
+ FlagIcon,
+ GlobeIcon,
+ MoreHorizontalIcon,
+ RefreshCwIcon,
+ SettingsIcon,
+ TrashIcon,
+} from "lucide-react";
+import { toast } from "sonner";
+import { mutate } from "swr";
+
+import { cn } from "@/lib/utils";
+
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { Input } from "@/components/ui/input";
+import { StatusBadge } from "@/components/ui/status-badge";
+import { TableCell, TableRow } from "@/components/ui/table";
+
+import { useDeleteDomainModal } from "./delete-domain-modal";
+import DomainConfiguration from "./domain-configuration";
+import { useDomainStatus } from "./use-domain-status";
+
+export default function DomainRow({
+ domain,
+ isDefault,
+ redirectUrl: initialRedirectUrl,
+ redirectsAllowed,
+ defaultOpen = false,
+ onDelete,
+}: {
+ domain: string;
+ isDefault: boolean;
+ redirectUrl?: string | null;
+ redirectsAllowed: boolean;
+ defaultOpen?: boolean;
+ onDelete: (deletedDomain: string) => void;
+}) {
+ const [showDetails, setShowDetails] = useState(defaultOpen);
+ const [menuOpen, setMenuOpen] = useState(false);
+
+ useEffect(() => {
+ if (defaultOpen) {
+ setShowDetails(true);
+ }
+ }, [defaultOpen]);
+ const [redirectUrl, setRedirectUrl] = useState(initialRedirectUrl || "");
+ const [savingRedirect, setSavingRedirect] = useState(false);
+
+ const {
+ status,
+ loading,
+ domainJson,
+ configJson,
+ mutate: mutateDomain,
+ } = useDomainStatus({
+ domain,
+ });
+ const teamInfo = useTeam();
+ const teamId = teamInfo?.currentTeam?.id;
+
+ const isInvalid =
+ status && !["Valid Configuration", "Pending Verification"].includes(status);
+
+ const { setShowDeleteDomainModal, DeleteDomainModal } = useDeleteDomainModal({
+ domain,
+ onDelete,
+ });
+
+ const handleSaveRedirectUrl = async () => {
+ setSavingRedirect(true);
+ try {
+ const response = await fetch(`/api/teams/${teamId}/domains/${domain}`, {
+ method: "PUT",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ redirectUrl: redirectUrl || null }),
+ });
+
+ if (!response.ok) {
+ const data = await response.json();
+ toast.error(data?.message || "Failed to save redirect URL");
+ return;
+ }
+
+ mutate(`/api/teams/${teamId}/domains`);
+ toast.success(
+ redirectUrl ? "Root redirect URL saved" : "Root redirect URL removed",
+ );
+ } catch {
+ toast.error("Failed to save redirect URL");
+ } finally {
+ setSavingRedirect(false);
+ }
+ };
+
+ const handleMakeDefault = async () => {
+ try {
+ const response = await fetch(`/api/teams/${teamId}/domains/${domain}`, {
+ method: "PATCH",
+ });
+
+ if (!response.ok) {
+ const data = await response.json().catch(() => null);
+ toast.error(data?.message || "Failed to set as default domain");
+ return;
+ }
+
+ mutate(`/api/teams/${teamId}/domains`);
+ toast.success("Default domain updated");
+ } catch {
+ toast.error("Failed to set as default domain");
+ }
+ };
+
+ return (
+ <>
+ <TableRow className="hover:bg-transparent">
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <GlobeIcon className="h-4 w-4 text-gray-400" />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {domain}
+ </span>
+ {isDefault ? (
+ <span className="flex items-center gap-1 rounded-full bg-sky-400/[.15] px-1.5 py-0.5 text-xs font-medium text-sky-600">
+ <FlagIcon className="hidden h-3 w-3 sm:block" />
+ Default
+ </span>
+ ) : null}
+ </div>
+ </TableCell>
+ <TableCell>
+ {status && !loading ? (
+ <StatusBadge
+ variant={
+ status === "Valid Configuration"
+ ? "success"
+ : status === "Pending Verification"
+ ? "pending"
+ : "error"
+ }
+ >
+ {status === "Valid Configuration"
+ ? "Active"
+ : status === "Pending Verification"
+ ? "Pending"
+ : "Invalid"}
+ </StatusBadge>
+ ) : (
+ <div className="h-6 w-16 animate-pulse rounded-md bg-gray-200 dark:bg-gray-700" />
+ )}
+ </TableCell>
+ <TableCell
+ className="text-right"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <div className="flex items-center justify-end gap-2">
+ <Button
+ variant="secondary"
+ size="icon"
+ className="relative h-8 w-8"
+ onClick={() => setShowDetails((s) => !s)}
+ data-state={showDetails ? "open" : "closed"}
+ aria-label="Domain settings"
+ >
+ <SettingsIcon
+ className={cn(
+ "h-4 w-4",
+ showDetails
+ ? "text-gray-800 dark:text-gray-200"
+ : "text-gray-600 dark:text-gray-400",
+ )}
+ />
+ {status && isInvalid && (
+ <div className="absolute -right-px -top-px h-[5px] w-[5px] rounded-full bg-destructive">
+ <div className="h-full w-full animate-pulse rounded-full ring-2 ring-destructive/30" />
+ </div>
+ )}
+ </Button>
+ <DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ aria-label="Open domain actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <DropdownMenuItem
+ disabled={isDefault}
+ onClick={handleMakeDefault}
+ >
+ <FlagIcon className="mr-2 h-4 w-4" />
+ Make default
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => mutateDomain()}
+ disabled={loading}
+ >
+ <RefreshCwIcon className="mr-2 h-4 w-4" />
+ Refresh
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ className="text-destructive transition-colors duration-200 focus:bg-destructive focus:text-destructive-foreground"
+ onClick={() => setShowDeleteDomainModal(true)}
+ >
+ <TrashIcon className="mr-2 h-4 w-4" />
+ Delete domain
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </TableCell>
+ </TableRow>
+
+ {showDetails ? (
+ <TableRow className="hover:bg-transparent">
+ <TableCell colSpan={3} className="bg-muted/20 p-0">
+ <div className="px-4 py-4">
+ {status ? (
+ status === "Valid Configuration" ? (
+ <div className="flex items-center gap-2 text-pretty rounded-lg bg-green-100/80 p-3 text-sm text-green-600">
+ <CircleCheckIcon className="h-5 w-5 shrink-0" />
+ <div>
+ Good news! Your DNS records are set up correctly, but it
+ can take some time for them to propagate globally.
+ </div>
+ </div>
+ ) : (
+ <DomainConfiguration
+ status={status}
+ response={{ domainJson, configJson }}
+ />
+ )
+ ) : (
+ <div className="h-6 w-32 animate-pulse rounded-md bg-gray-200 dark:bg-gray-700" />
+ )}
+
+ {/* Root domain redirect */}
+ <div className="mt-4 rounded-lg border border-gray-200 p-4 dark:border-gray-700">
+ <div className="flex items-center gap-2 text-sm font-medium text-foreground">
+ <ExternalLinkIcon className="h-4 w-4" />
+ Root Domain Redirect
+ </div>
+ {redirectsAllowed ? (
+ <>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Redirect visitors who land on{" "}
+ <span className="font-medium">{domain}</span> to a specific
+ URL. Leave empty to redirect to papermark.com.
+ </p>
+ <div className="mt-3 flex items-center gap-2">
+ <Input
+ type="url"
+ placeholder="https://example.com"
+ value={redirectUrl}
+ onChange={(e) => setRedirectUrl(e.target.value)}
+ className="h-9 flex-1"
+ />
+ <Button
+ size="sm"
+ onClick={handleSaveRedirectUrl}
+ disabled={savingRedirect}
+ className="h-9 shrink-0"
+ >
+ {savingRedirect ? "Saving..." : "Save"}
+ </Button>
+ </div>
+ </>
+ ) : (
+ <p className="mt-1 text-xs text-muted-foreground">
+ Root domain redirects require a{" "}
+ <span className="font-semibold">Business</span> plan or
+ higher.
+ </p>
+ )}
+ </div>
+ </div>
+ </TableCell>
+ </TableRow>
+ ) : null}
+
+ <DeleteDomainModal />
+ </>
+ );
+}
diff --git a/components/settings/settings-header.tsx b/components/settings/settings-header.tsx
index 49fdb3b7..d9de5ded 100644
--- a/components/settings/settings-header.tsx
+++ b/components/settings/settings-header.tsx
@@ -1,14 +1,11 @@
import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { useIsAdmin } from "@/lib/hooks/use-is-admin";
-import { usePlan } from "@/lib/swr/use-billing";
import { NavMenu } from "../navigation-menu";
export function SettingsHeader() {
const { features } = useFeatureFlags();
const { isAdmin } = useIsAdmin();
- const { isDatarooms, isTrial } = usePlan();
- const hasTokensAccess = isDatarooms || isTrial || !!features?.tokens;
return (
<header>
@@ -55,11 +52,6 @@ export function SettingsHeader() {
href: `/settings/agreements`,
segment: "agreements",
},
- {
- label: "Webhooks",
- href: `/settings/webhooks`,
- segment: "webhooks",
- },
{
label: "Notifications",
href: `/settings/notifications`,
@@ -77,16 +69,14 @@ export function SettingsHeader() {
disabled: !features?.ai,
},
{
- label: "Tokens",
- href: `/settings/tokens`,
- segment: "tokens",
- disabled: !hasTokensAccess,
+ label: "Webhooks",
+ href: `/settings/webhooks`,
+ segment: "webhooks",
},
{
- label: "API",
- href: `/settings/incoming-webhooks`,
- segment: "incoming-webhooks",
- disabled: !features?.incomingWebhooks,
+ label: "API Keys",
+ href: `/settings/tokens`,
+ segment: "tokens",
},
{
label: "Security",
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsx
index 598abf57..092cb4fa 100644
--- a/components/sidebar/app-sidebar.tsx
+++ b/components/sidebar/app-sidebar.tsx
@@ -1,5 +1,6 @@
"use client";
+import Link from "next/link";
import { useRouter } from "next/router";
import * as React from "react";
@@ -49,13 +50,8 @@ export function AppSidebarContent() {
const [showSlackBanner, setShowSlackBanner] = useState<boolean | null>(null);
const { currentTeam, teams, setCurrentTeam, isLoading }: TeamContextType =
useTeam() || initialState;
- const {
- isBusiness,
- isDatarooms,
- isDataroomsPlus,
- isFree,
- isTrial,
- } = usePlan();
+ const { isBusiness, isDatarooms, isDataroomsPlus, isFree, isTrial } =
+ usePlan();
const { limits } = useLimits();
const linksLimit = limits?.links;
@@ -195,15 +191,20 @@ export function AppSidebarContent() {
url: "/settings/notifications",
current: router.pathname.includes("settings/notifications"),
},
+ {
+ title: "Slack",
+ url: "/settings/slack",
+ current: router.pathname.includes("settings/slack"),
+ },
{
title: "Webhooks",
url: "/settings/webhooks",
current: router.pathname.includes("settings/webhooks"),
},
{
- title: "Slack",
- url: "/settings/slack",
- current: router.pathname.includes("settings/slack"),
+ title: "API Keys",
+ url: "/settings/tokens",
+ current: router.pathname.includes("settings/tokens"),
},
...(isAdmin
? [
@@ -307,7 +308,13 @@ export function AppSidebarContent() {
) : null}
{linksLimit || documentsLimit ? (
<p className="mt-2 px-2 text-xs text-muted-foreground">
- Change plan to increase usage limits
+ <Link
+ href="/settings/upgrade"
+ className="font-medium text-foreground underline-offset-2 hover:underline"
+ >
+ Change plan
+ </Link>{" "}
+ to increase limits
</p>
) : null}
</div>
diff --git a/components/sidebar/banners/slack-banner.tsx b/components/sidebar/banners/slack-banner.tsx
index b563195a..d803cb48 100644
--- a/components/sidebar/banners/slack-banner.tsx
+++ b/components/sidebar/banners/slack-banner.tsx
@@ -8,7 +8,6 @@ import { useAnalytics } from "@/lib/analytics";
import { SlackIcon } from "@/components/shared/icons/slack-icon";
import X from "@/components/shared/icons/x";
-import { Button } from "@/components/ui/button";
export default function SlackBanner({
setShowSlackBanner,
@@ -34,30 +33,24 @@ export default function SlackBanner({
};
return (
- <aside className="relative mb-2 flex w-full flex-col justify-center rounded-lg border border-gray-700 bg-background p-4 text-foreground">
+ <aside className="relative mb-2 flex w-full items-center gap-2 rounded-lg border border-gray-200 bg-background px-3 py-2 text-foreground">
+ <SlackIcon className="h-4 w-4 shrink-0" />
+ <span className="grow text-sm text-foreground">Connect Slack</span>
+ <button
+ type="button"
+ onClick={handleConnectSlack}
+ className="shrink-0 rounded-sm text-sm font-medium text-foreground ring-offset-background transition-colors hover:text-foreground/80 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
+ >
+ Set up
+ </button>
<button
type="button"
onClick={handleHideBanner}
- className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
+ className="shrink-0 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
>
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</button>
- <div className="flex items-center space-x-2">
- <SlackIcon className="h-5 w-5" />
- <span className="text-sm font-bold">Connect Slack</span>
- </div>
- <p className="my-4 text-sm">Get visit notifications in Slack channel.</p>
- <div className="flex">
- <Button
- type="button"
- variant="outline"
- className="grow"
- onClick={handleConnectSlack}
- >
- Set up Slack
- </Button>
- </div>
</aside>
);
}
diff --git a/components/sidebar/dataroom-sidebar.tsx b/components/sidebar/dataroom-sidebar.tsx
index 5f47d68f..f47578da 100644
--- a/components/sidebar/dataroom-sidebar.tsx
+++ b/components/sidebar/dataroom-sidebar.tsx
@@ -40,7 +40,6 @@ import {
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
-import { Skeleton } from "@/components/ui/skeleton";
import {
SidebarContent,
SidebarGroup,
@@ -54,6 +53,7 @@ import {
SidebarMenuSubItem,
useSidebar,
} from "@/components/ui/sidebar";
+import { Skeleton } from "@/components/ui/skeleton";
import {
Tooltip,
TooltipContent,
@@ -156,6 +156,11 @@ export function DataroomSidebarContent() {
href: `/datarooms/${dataroomId}/settings/file-permissions`,
icon: ShieldIcon,
},
+ {
+ title: "Dataroom Team",
+ href: `/datarooms/${dataroomId}/settings/team`,
+ icon: UsersIcon,
+ },
...(isDataroomMember
? []
: [
@@ -261,29 +266,31 @@ export function DataroomSidebarContent() {
return (
<>
<SidebarHeader className="gap-y-3 pt-0">
- <Link
- href="/datarooms"
- className="group/back flex items-center gap-2 rounded-lg text-foreground"
- >
- <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground transition-transform duration-150 group-hover/back:-translate-x-0.5">
- <ChevronLeftIcon className="h-4 w-4" />
- </span>
- <div className="min-w-0 group-data-[collapsible=icon]:hidden">
- <div className="flex items-center gap-1.5">
- <ScrollingText className="text-lg font-semibold leading-tight">
- {dataroom?.internalName || dataroom?.name || "Loading..."}
- </ScrollingText>
- {dataroom?.isFrozen && (
- <SnowflakeIcon className="h-4 w-4 shrink-0 text-blue-500" />
- )}
+ <div className="flex items-center gap-2">
+ <Link
+ href="/datarooms"
+ className="group/back flex min-w-0 flex-1 items-center gap-2 rounded-lg text-foreground"
+ >
+ <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground transition-transform duration-150 group-hover/back:-translate-x-0.5">
+ <ChevronLeftIcon className="h-4 w-4" />
+ </span>
+ <div className="min-w-0 group-data-[collapsible=icon]:hidden">
+ <div className="flex items-center gap-1.5">
+ <ScrollingText className="text-lg font-semibold leading-tight">
+ {dataroom?.internalName || dataroom?.name || "Loading..."}
+ </ScrollingText>
+ {dataroom?.isFrozen && (
+ <SnowflakeIcon className="h-4 w-4 shrink-0 text-blue-500" />
+ )}
+ </div>
+ {dataroom?.internalName && dataroom?.name ? (
+ <p className="truncate text-xs text-muted-foreground">
+ {dataroom.name}
+ </p>
+ ) : null}
</div>
- {dataroom?.internalName && dataroom?.name ? (
- <p className="truncate text-xs text-muted-foreground">
- {dataroom.name}
- </p>
- ) : null}
- </div>
- </Link>
+ </Link>
+ </div>
</SidebarHeader>
<SidebarContent>
diff --git a/components/teams/add-team-member-modal.tsx b/components/teams/add-team-member-modal.tsx
index 01c54102..6f3cfbdb 100644
--- a/components/teams/add-team-member-modal.tsx
+++ b/components/teams/add-team-member-modal.tsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { useRouter } from "next/router";
import { useTeam } from "@/context/team-context";
@@ -37,21 +37,58 @@ export function AddTeamMembers({
open,
setOpen,
children,
+ defaultRole = "MEMBER",
+ defaultDataroomIds,
+ currentDataroomId,
+ redirectToPeople = true,
+ onInvited,
}: {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
children?: React.ReactNode;
+ /** Preselect a role (still editable). Defaults to "MEMBER". */
+ defaultRole?: InviteRole;
+ /** Preselect data rooms for a DATAROOM_MEMBER invite (still editable). */
+ defaultDataroomIds?: string[];
+ /** The data room the modal was opened from. It's pinned to the top of the list with a "This data room" hint. */
+ currentDataroomId?: string;
+ /** Redirect to /settings/people after a successful invite. Defaults to true. */
+ redirectToPeople?: boolean;
+ /** Called after a successful invite (e.g. to revalidate a scoped list). */
+ onInvited?: () => void;
}) {
const [email, setEmail] = useState<string>("");
- const [role, setRole] = useState<InviteRole>("MEMBER");
- const [selectedDataroomIds, setSelectedDataroomIds] = useState<string[]>([]);
+ const [role, setRole] = useState<InviteRole>(defaultRole);
+ const [selectedDataroomIds, setSelectedDataroomIds] = useState<string[]>(
+ defaultDataroomIds ?? [],
+ );
const [loading, setLoading] = useState<boolean>(false);
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
const analytics = useAnalytics();
const router = useRouter();
const { datarooms } = useDataroomsSimple();
- const { isDatarooms } = usePlan();
+ const { isDatarooms, isTrial } = usePlan();
+
+ // Pin the data room the modal was opened from to the top of the list.
+ const orderedDatarooms = useMemo(() => {
+ if (!datarooms) return datarooms;
+ if (!currentDataroomId) return datarooms;
+ const current = datarooms.find((d) => d.id === currentDataroomId);
+ if (!current) return datarooms;
+ return [current, ...datarooms.filter((d) => d.id !== currentDataroomId)];
+ }, [datarooms, currentDataroomId]);
+
+ // Reset to the preselected values each time the modal opens so the data-room
+ // context (role + room) is applied, while staying editable by the user.
+ useEffect(() => {
+ if (open) {
+ setEmail("");
+ setRole(defaultRole);
+ setSelectedDataroomIds(defaultDataroomIds ?? []);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [open]);
const toggleDataroom = (id: string) => {
setSelectedDataroomIds((prev) =>
@@ -112,14 +149,18 @@ export function AddTeamMembers({
toast.success("An invitation email has been sent!");
setOpen(false);
setLoading(false);
-
- // Redirect to team members page
- router.push("/settings/people");
+
+ onInvited?.();
+
+ // Redirect to the team members page (skipped when invoked from a data room).
+ if (redirectToPeople) {
+ router.push("/settings/people");
+ }
};
return (
<Dialog open={open} onOpenChange={setOpen}>
- <DialogTrigger asChild>{children}</DialogTrigger>
+ {children ? <DialogTrigger asChild>{children}</DialogTrigger> : null}
<DialogContent className="sm:max-w-[425px]">
<DialogHeader className="text-start">
<DialogTitle>Add Member</DialogTitle>
@@ -157,9 +198,9 @@ export function AddTeamMembers({
<SelectItem value="MEMBER">Member</SelectItem>
<SelectItem
value="DATAROOM_MEMBER"
- disabled={!isDatarooms}
+ disabled={!isDatarooms && !isTrial}
trailingContent={
- !isDatarooms ? (
+ !isDatarooms && !isTrial ? (
<span className="ml-auto pl-3 text-xs text-muted-foreground">
Data Rooms plan
</span>
@@ -181,8 +222,8 @@ export function AddTeamMembers({
</p>
</div>
<div className="max-h-44 space-y-0.5 overflow-y-auto rounded-md border p-1">
- {datarooms && datarooms.length > 0 ? (
- datarooms.map((dataroom) => (
+ {orderedDatarooms && orderedDatarooms.length > 0 ? (
+ orderedDatarooms.map((dataroom) => (
<div
key={dataroom.id}
className="flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm hover:bg-muted"
@@ -195,9 +236,16 @@ export function AddTeamMembers({
/>
<label
htmlFor={`add-dataroom-${dataroom.id}`}
- className="flex-1 cursor-pointer truncate"
+ className="flex flex-1 cursor-pointer items-center gap-2 truncate"
>
- {dataroom.internalName || dataroom.name}
+ <span className="truncate">
+ {dataroom.internalName || dataroom.name}
+ </span>
+ {dataroom.id === currentDataroomId ? (
+ <span className="shrink-0 rounded-full border bg-background px-2 py-0.5 text-xs font-medium text-muted-foreground">
+ This data room
+ </span>
+ ) : null}
</label>
</div>
))
diff --git a/components/tokens/add-edit-token-modal.tsx b/components/tokens/add-edit-token-modal.tsx
index a713fdff..4a646d75 100644
--- a/components/tokens/add-edit-token-modal.tsx
+++ b/components/tokens/add-edit-token-modal.tsx
@@ -8,12 +8,15 @@ import {
} from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { CircleHelpIcon } from "lucide-react";
import { toast } from "sonner";
+import { usePlan } from "@/lib/swr/use-billing";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
+import { UpgradeButton } from "@/components/ui/upgrade-button";
import {
Dialog,
DialogContent,
@@ -62,6 +65,8 @@ function AddEditTokenModal({
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
const isEdit = Boolean(token);
+ const { isFree, isPro, isTrial } = usePlan();
+ const showUpgrade = (isFree || isPro) && !isTrial;
const initial = useMemo(
() =>
@@ -106,6 +111,7 @@ function AddEditTokenModal({
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();
+ if (showUpgrade) return;
if (preset === "restricted" && scopesList.length === 0) {
toast.error("Select at least one resource permission");
return;
@@ -318,14 +324,26 @@ function AddEditTokenModal({
</div>
) : null}
- <Button
- type="submit"
- disabled={submitDisabled}
- loading={isLoading}
- className="w-full bg-gray-900 text-gray-50 hover:bg-gray-900/90"
- >
- {isEdit ? "Save changes" : "Create API key"}
- </Button>
+ {showUpgrade ? (
+ <UpgradeButton
+ text="Business"
+ customText="Upgrade to save API Key"
+ clickedPlan={PlanEnum.Business}
+ trigger="create_token"
+ highlightItem={["api"]}
+ className="w-full justify-center"
+ key="create-token"
+ />
+ ) : (
+ <Button
+ type="submit"
+ disabled={submitDisabled}
+ loading={isLoading}
+ className="w-full bg-gray-900 text-gray-50 hover:bg-gray-900/90"
+ >
+ {isEdit ? "Save changes" : "Create API key"}
+ </Button>
+ )}
</form>
</DialogContent>
</Dialog>
diff --git a/components/welcome/dataroom-trial.tsx b/components/welcome/dataroom-trial.tsx
index e2214fe7..2fbac7a2 100644
--- a/components/welcome/dataroom-trial.tsx
+++ b/components/welcome/dataroom-trial.tsx
@@ -398,13 +398,13 @@ export default function DataroomTrial() {
plan. <br /> */}
No credit card is required. After the trial, upgrade to{" "}
<UpgradePlanModal
- clickedPlan={PlanEnum.Business}
+ clickedPlan={PlanEnum.DataRooms}
highlightItem={["datarooms"]}
trigger="dataroom_trial_form"
>
<button className="underline">Papermark Data Rooms</button>
</UpgradePlanModal>{" "}
- to continue using Data Room plan features.
+ to continue using advanced data room features.
</div>
</div>
</form>
diff --git a/lib/hooks/use-last-visited.ts b/lib/hooks/use-last-visited.ts
new file mode 100644
index 00000000..299d6db2
--- /dev/null
+++ b/lib/hooks/use-last-visited.ts
@@ -0,0 +1,137 @@
+import { useRouter } from "next/router";
+
+import { useEffect, useRef, useState } from "react";
+
+// Versioned key so the schema can evolve without colliding with old values.
+const STORAGE_KEY = "papermark:last-visited:v1";
+// Per-tab session flag: marks that we've already handled "platform entry",
+// so a later manual visit to /dashboard does not bounce the user away.
+const ENTRY_FLAG_KEY = "papermark:entry-handled";
+// Ignore stale destinations so users are not teleported to something they
+// opened weeks ago.
+const MAX_AGE_MS = 1000 * 60 * 60 * 24 * 30; // 30 days
+
+type LastVisited = { path: string; ts: number };
+
+// Paths that should never be remembered as a "last visited" destination, nor
+// act as the page we redirect away from on entry. The default landing page
+// (/dashboard) and the onboarding flow (/welcome) are intentionally excluded.
+const TRACK_DENYLIST = [
+ "/dashboard",
+ "/welcome",
+ "/login",
+ "/register",
+ "/auth",
+];
+
+function getPathname(path: string): string {
+ return path.split(/[?#]/)[0];
+}
+
+function isTrackablePath(path: string): boolean {
+ const pathname = getPathname(path);
+ return !TRACK_DENYLIST.some(
+ (denied) => pathname === denied || pathname.startsWith(`${denied}/`),
+ );
+}
+
+export function saveLastVisited(path: string) {
+ if (typeof window === "undefined") return;
+ try {
+ const value: LastVisited = { path, ts: Date.now() };
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(value));
+ } catch {
+ // localStorage throws in private mode / when full — safe to ignore.
+ }
+}
+
+export function getLastVisited(): LastVisited | null {
+ if (typeof window === "undefined") return null;
+ try {
+ const raw = window.localStorage.getItem(STORAGE_KEY);
+ if (!raw) return null;
+ const parsed = JSON.parse(raw) as LastVisited;
+ if (!parsed?.path || typeof parsed.ts !== "number") return null;
+ if (Date.now() - parsed.ts > MAX_AGE_MS) return null;
+ return parsed;
+ } catch {
+ return null;
+ }
+}
+
+export function clearLastVisited() {
+ if (typeof window === "undefined") return;
+ try {
+ window.localStorage.removeItem(STORAGE_KEY);
+ } catch {
+ // ignore
+ }
+}
+
+function isEntryHandled(): boolean {
+ if (typeof window === "undefined") return true;
+ try {
+ return window.sessionStorage.getItem(ENTRY_FLAG_KEY) === "1";
+ } catch {
+ return true;
+ }
+}
+
+function markEntryHandled() {
+ if (typeof window === "undefined") return;
+ try {
+ window.sessionStorage.setItem(ENTRY_FLAG_KEY, "1");
+ } catch {
+ // ignore
+ }
+}
+
+/**
+ * Records the user's current location so we can route them back here next time
+ * they enter the platform. Mount once globally for authenticated app pages.
+ */
+export function useTrackLastVisited() {
+ const router = useRouter();
+
+ useEffect(() => {
+ if (isTrackablePath(router.asPath)) {
+ saveLastVisited(router.asPath);
+ }
+ }, [router.asPath]);
+}
+
+/**
+ * On the first load of /dashboard in a tab session (i.e. platform entry),
+ * redirect to the last meaningful location the user visited, if any. Manual
+ * navigations to /dashboard within the same session are left untouched.
+ *
+ * Returns whether a redirect is in flight so the caller can render a loader
+ * instead of flashing the dashboard.
+ */
+export function useEntryRedirect(): boolean {
+ const router = useRouter();
+ const [redirecting, setRedirecting] = useState(false);
+ const ran = useRef(false);
+
+ useEffect(() => {
+ if (ran.current) return;
+ ran.current = true;
+
+ if (isEntryHandled()) return;
+ markEntryHandled();
+
+ const last = getLastVisited();
+ const target = last?.path;
+ if (!target || getPathname(target) === "/dashboard") return;
+
+ setRedirecting(true);
+ void router.replace(target).catch(() => {
+ // The stored destination may have been deleted or access revoked; drop
+ // it and stay on the dashboard rather than looping on a dead route.
+ clearLastVisited();
+ setRedirecting(false);
+ });
+ }, [router]);
+
+ return redirecting;
+}
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index b5b3ec98..17265003 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -70,7 +70,9 @@ export default async function AppMiddleware(req: NextRequest) {
// action link identifies the link and visitor email). Preserve the full
// search string for those so it survives the login round-trip.
const preserveSearch =
- path === "/auth/confirm-email-change" || path.startsWith("/access/");
+ path === "/auth/confirm-email-change" ||
+ path === "/welcome" ||
+ path.startsWith("/access/");
const nextPath = preserveSearch ? `${path}${url.search}` : path;
loginUrl.searchParams.set("next", nextPath);
diff --git a/lib/swr/use-dataroom-members.ts b/lib/swr/use-dataroom-members.ts
new file mode 100644
index 00000000..9ebaa8de
--- /dev/null
+++ b/lib/swr/use-dataroom-members.ts
@@ -0,0 +1,52 @@
+import { useTeam } from "@/context/team-context";
+import useSWR from "swr";
+
+import { TeamRole } from "@/lib/types";
+import { fetcher } from "@/lib/utils";
+
+export interface DataroomTeamMember {
+ userId: string;
+ name: string | null;
+ email: string;
+ role: TeamRole;
+ status: "ACTIVE" | "BLOCKED_TRIAL_EXPIRED";
+ /** True when access is scoped to specific rooms (DATAROOM_MEMBER). */
+ scoped: boolean;
+}
+
+export interface DataroomTeamInvitation {
+ email: string;
+ expires: string;
+}
+
+interface DataroomMembersResponse {
+ members: DataroomTeamMember[];
+ invitations: DataroomTeamInvitation[];
+}
+
+/**
+ * Internal team members with access to a single data room. `enabled` lets the
+ * caller skip the request when the team isn't entitled to the feature.
+ */
+export function useDataroomMembers(
+ dataroomId: string | undefined,
+ enabled: boolean = true,
+) {
+ const { currentTeamId } = useTeam();
+
+ const { data, error, isLoading, mutate } = useSWR<DataroomMembersResponse>(
+ enabled && currentTeamId && dataroomId
+ ? `/api/teams/${currentTeamId}/datarooms/${dataroomId}/members`
+ : null,
+ fetcher,
+ { dedupingInterval: 10000 },
+ );
+
+ return {
+ members: data?.members ?? [],
+ invitations: data?.invitations ?? [],
+ loading: isLoading,
+ error,
+ mutate,
+ };
+}
diff --git a/pages/_app.tsx b/pages/_app.tsx
index 626ee61d..8061e952 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -9,6 +9,7 @@ import { SessionProvider } from "next-auth/react";
import { NuqsAdapter } from "nuqs/adapters/next/pages";
import { EXCLUDED_PATHS } from "@/lib/constants";
+import { useTrackLastVisited } from "@/lib/hooks/use-last-visited";
import { PostHogGroupSync } from "@/components/providers/posthog-group-sync";
import { PostHogCustomProvider } from "@/components/providers/posthog-provider";
@@ -20,6 +21,11 @@ import "@/styles/globals.css";
const inter = Inter({ subsets: ["latin"] });
+function LastVisitedTracker() {
+ useTrackLastVisited();
+ return null;
+}
+
export default function App({
Component,
pageProps: { session, ...pageProps },
@@ -84,6 +90,7 @@ export default function App({
) : (
<TeamProvider>
<PostHogGroupSync />
+ <LastVisitedTracker />
<UploadProgressProvider>
<Component {...pageProps} />
</UploadProgressProvider>
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/members.ts b/pages/api/teams/[teamId]/datarooms/[id]/members.ts
new file mode 100644
index 00000000..1dfca9b4
--- /dev/null
+++ b/pages/api/teams/[teamId]/datarooms/[id]/members.ts
@@ -0,0 +1,156 @@
+import { withTeamApi } from "@/lib/api/auth/with-session-team";
+import { errorhandler } from "@/lib/errorHandler";
+import prisma from "@/lib/prisma";
+
+/**
+ * Per-dataroom internal team membership (read + remove).
+ *
+ * GET — list team members who can access this room (full members always do;
+ * DATAROOM_MEMBERs only when assigned via UserDataroom) + pending
+ * invitations scoped to this room.
+ * DELETE — remove a scoped member's access to this room ({ userId }) or revoke a
+ * pending invitation ({ email }).
+ *
+ * Inviting/adding members reuses the team invite flow
+ * (POST /api/teams/[teamId]/invite) with role=DATAROOM_MEMBER and the room
+ * preselected, so seat limits and invitations stay consistent team-wide.
+ *
+ * Gated to the Data Rooms plan and higher; removal is ADMIN/MANAGER-only.
+ */
+export default withTeamApi(
+ async ({ req, res, teamId, role }) => {
+ const { id: dataroomId } = req.query as { id: string };
+
+ // Ensure the room belongs to the team before doing anything else.
+ const dataroom = await prisma.dataroom.findUnique({
+ where: { id: dataroomId, teamId },
+ select: { id: true, name: true },
+ });
+ if (!dataroom) {
+ return res.status(404).json({ error: "Data room not found" });
+ }
+
+ if (req.method === "GET") {
+ try {
+ const [teamUsers, roomAssignments, invitations] = await Promise.all([
+ prisma.userTeam.findMany({
+ where: { teamId },
+ select: {
+ role: true,
+ status: true,
+ userId: true,
+ user: { select: { name: true, email: true } },
+ },
+ }),
+ prisma.userDataroom.findMany({
+ where: { teamId, dataroomId },
+ select: { userId: true },
+ }),
+ prisma.invitation.findMany({
+ where: {
+ teamId,
+ role: "DATAROOM_MEMBER",
+ dataroomIds: { has: dataroomId },
+ },
+ select: { email: true, expires: true },
+ }),
+ ]);
+
+ const assignedUserIds = new Set(
+ roomAssignments.map((row) => row.userId),
+ );
+
+ const members = teamUsers
+ .filter((member) => {
+ // Full team members have access to every room. Scoped members only
+ // count when explicitly assigned to this one.
+ if (member.role === "DATAROOM_MEMBER") {
+ return assignedUserIds.has(member.userId);
+ }
+ return true;
+ })
+ .map((member) => ({
+ userId: member.userId,
+ name: member.user.name,
+ email: member.user.email,
+ role: member.role,
+ status: member.status,
+ scoped: member.role === "DATAROOM_MEMBER",
+ }));
+
+ return res.status(200).json({ members, invitations });
+ } catch (error) {
+ return errorhandler(error, res);
+ }
+ }
+
+ if (req.method === "DELETE") {
+ if (role !== "ADMIN" && role !== "MANAGER") {
+ return res.status(403).json({
+ error: "Only admins and managers can manage data room members.",
+ });
+ }
+
+ const { userId: targetUserId, email } = req.body as {
+ userId?: string;
+ email?: string;
+ };
+
+ try {
+ // Revoke a pending invitation scoped to this room.
+ if (email) {
+ await prisma.invitation.deleteMany({
+ where: {
+ teamId,
+ email,
+ role: "DATAROOM_MEMBER",
+ dataroomIds: { has: dataroomId },
+ },
+ });
+ return res.status(204).end();
+ }
+
+ if (!targetUserId) {
+ return res
+ .status(400)
+ .json({ error: "Provide a userId or email to remove." });
+ }
+
+ const target = await prisma.userTeam.findUnique({
+ where: { userId_teamId: { userId: targetUserId, teamId } },
+ select: { role: true },
+ });
+
+ if (!target) {
+ return res
+ .status(400)
+ .json({ error: "This user is not part of the team." });
+ }
+
+ if (target.role !== "DATAROOM_MEMBER") {
+ return res.status(400).json({
+ error:
+ "Full team members have access to all data rooms. Change their role in Settings → People to restrict access.",
+ });
+ }
+
+ await prisma.userDataroom.deleteMany({
+ where: { userId: targetUserId, teamId, dataroomId },
+ });
+
+ return res.status(204).end();
+ } catch (error) {
+ return errorhandler(error, res);
+ }
+ }
+
+ res.setHeader("Allow", ["GET", "DELETE"]);
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
+ },
+ {
+ requiredPermissions: ["datarooms.read"],
+ requiredPlan: (plan) =>
+ plan.startsWith("datarooms") || plan.includes("drtrial"),
+ dataroomParam: "id",
+ },
+);
diff --git a/pages/api/teams/[teamId]/tokens/index.ts b/pages/api/teams/[teamId]/tokens/index.ts
index c678ba5b..084eba73 100644
--- a/pages/api/teams/[teamId]/tokens/index.ts
+++ b/pages/api/teams/[teamId]/tokens/index.ts
@@ -36,7 +36,7 @@ export default async function handle(
return res.status(403).json({ error: "Unauthorized" });
}
- // Tokens require a Data Rooms plan or higher (or a Data Rooms trial), or the
+ // Tokens require a Business plan or higher (or a Data Rooms trial), or the
// `tokens` beta feature flag enabled for the team. Only hit Edge Config for
// the flag when the plan check fails, so paid teams skip that latency.
const team = await prisma.team.findUnique({
@@ -45,7 +45,9 @@ export default async function handle(
});
const plan = team?.plan ?? "";
let hasTokensAccess =
- plan.includes("datarooms") || plan.includes("drtrial");
+ plan.includes("business") ||
+ plan.includes("datarooms") ||
+ plan.includes("drtrial");
if (!hasTokensAccess) {
const features = await getFeatureFlags({ teamId });
hasTokensAccess = Boolean(features.tokens);
@@ -53,7 +55,7 @@ export default async function handle(
if (!hasTokensAccess) {
return res
.status(403)
- .json({ error: "This feature requires a Data Rooms plan or higher." });
+ .json({ error: "This feature requires a Business plan or higher." });
}
if (req.method === "GET") {
diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx
index 16d30d4f..a7af7ec2 100644
--- a/pages/dashboard.tsx
+++ b/pages/dashboard.tsx
@@ -8,6 +8,7 @@ import { BarChart3, FileTextIcon, LinkIcon } from "lucide-react";
import { toast } from "sonner";
import useSWR from "swr";
+import { useEntryRedirect } from "@/lib/hooks/use-last-visited";
import { usePlan } from "@/lib/swr/use-billing";
import { fetcher } from "@/lib/utils";
@@ -23,6 +24,7 @@ import ViewsTable from "@/components/analytics/views-table";
import VisitorsTable from "@/components/analytics/visitors-table";
import AppLayout from "@/components/layouts/app";
import { TabMenu } from "@/components/tab-menu";
+import LoadingSpinner from "@/components/ui/loading-spinner";
interface OverviewData {
counts: {
@@ -44,6 +46,8 @@ export const defaultRange = {
export default function DashboardPage() {
const router = useRouter();
+ // On platform entry, route the user back to where they last were (Option 2).
+ const isRedirecting = useEntryRedirect();
const teamInfo = useTeam();
const { plan, trial } = usePlan();
const slug = useRef<boolean>(false);
@@ -127,6 +131,16 @@ export default function DashboardPage() {
const showEmptyOverlay = hasNoActivity && !hasLinks;
const showSharePrompt = hasNoActivity && hasLinks;
+ if (isRedirecting) {
+ return (
+ <AppLayout>
+ <div className="flex h-[60vh] items-center justify-center">
+ <LoadingSpinner className="h-6 w-6 text-muted-foreground" />
+ </div>
+ </AppLayout>
+ );
+ }
+
return (
<AppLayout>
<div className="flex-1 space-y-4 p-4 pt-6 md:p-8">
@@ -162,7 +176,7 @@ export default function DashboardPage() {
<div className="flex flex-col items-center gap-2 text-center">
<LinkIcon className="h-8 w-8 text-muted-foreground" />
<p className="text-sm font-medium text-foreground">
- Share your link to see activity
+ Share access link to see activity
</p>
<p className="text-xs text-muted-foreground">
diff --git a/pages/datarooms/[id]/settings/team.tsx b/pages/datarooms/[id]/settings/team.tsx
new file mode 100644
index 00000000..2f32ae75
--- /dev/null
+++ b/pages/datarooms/[id]/settings/team.tsx
@@ -0,0 +1,73 @@
+import { PlanEnum } from "@/ee/stripe/constants";
+
+import { usePlan } from "@/lib/swr/use-billing";
+import { useDataroom } from "@/lib/swr/use-dataroom";
+
+import DataroomTeamMembers from "@/components/datarooms/settings/dataroom-team-members";
+import AppLayout from "@/components/layouts/app";
+import { FeaturePreview } from "@/components/ui/feature-preview";
+
+export default function DataroomTeamSettings() {
+ const { dataroom } = useDataroom();
+ const { isDatarooms, isTrial } = usePlan();
+
+ if (!dataroom) {
+ return <div>Loading...</div>;
+ }
+
+ const hasAccess = isDatarooms || isTrial;
+
+ return (
+ <AppLayout>
+ <main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
+ <div className="space-y-1">
+ <h3 className="text-2xl font-semibold tracking-tight text-foreground">
+ Team members
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ Add teammates to this data room and manage who can access it.
+ </p>
+ </div>
+
+ {hasAccess ? (
+ <DataroomTeamMembers
+ dataroomId={dataroom.id}
+ dataroomName={dataroom.name}
+ />
+ ) : (
+ <FeaturePreview
+ title="Add team members to this data room"
+ description="Give teammates access to a single data room. Available on the Data Rooms plan and higher."
+ requiredPlan={PlanEnum.DataRooms}
+ trigger="dataroom_team_members"
+ upgradeButtonText="Data Rooms"
+ highlightItem={["assign"]}
+ >
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
+ <div className="space-y-1">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Members
+ </h2>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ People on your team with access to this data room.
+ </p>
+ </div>
+ </div>
+ <div className="p-6">
+ <div className="space-y-2">
+ {[1, 2, 3].map((i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
+ </div>
+ </div>
+ </FeaturePreview>
+ )}
+ </main>
+ </AppLayout>
+ );
+}
diff --git a/pages/settings/agreements.tsx b/pages/settings/agreements.tsx
index 8ac6d9de..97a6fa50 100644
--- a/pages/settings/agreements.tsx
+++ b/pages/settings/agreements.tsx
@@ -2,7 +2,7 @@ import { useCallback, useMemo, useState } from "react";
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
-import { CircleHelpIcon, FileTextIcon, PlusIcon } from "lucide-react";
+import { CircleHelpIcon, FileTextIcon } from "lucide-react";
import { mutate } from "swr";
import {
@@ -11,11 +11,18 @@ import {
} from "@/lib/swr/use-agreements";
import { usePlan } from "@/lib/swr/use-billing";
-import AgreementCard from "@/components/agreements/agreement-card";
+import AgreementRow from "@/components/agreements/agreement-row";
import AppLayout from "@/components/layouts/app";
import AgreementSheet from "@/components/links/link-sheet/agreement-panel";
import { SettingsHeader } from "@/components/settings/settings-header";
import { Button } from "@/components/ui/button";
+import {
+ Table,
+ TableBody,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
import { BadgeTooltip } from "@/components/ui/tooltip";
import { createUpgradeButton } from "@/components/ui/upgrade-button";
@@ -66,9 +73,9 @@ export default function NdaAgreements() {
[],
);
- const handleSheetOpenChange: React.Dispatch<
- React.SetStateAction<boolean>
- > = (value) => {
+ const handleSheetOpenChange: React.Dispatch<React.SetStateAction<boolean>> = (
+ value,
+ ) => {
setIsOpen((prev) => {
const next = typeof value === "function" ? value(prev) : value;
if (!next) {
@@ -87,48 +94,52 @@ export default function NdaAgreements() {
<AppLayout>
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 dark:border-gray-800 sm:flex-row sm:items-center sm:p-6">
<div className="space-y-1">
- <h3 className="text-2xl font-semibold tracking-tight text-foreground">
- Agreements
- </h3>
- <p className="flx-row flex items-center gap-2 text-sm text-muted-foreground">
- Manage your one-click agreements for document sharing and data
- rooms.
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Agreements
+ </h2>
<BadgeTooltip
content="How to require NDA agreement before viewing documents?"
key="nda-help"
linkText="Learn more"
link="https://www.papermark.com/help/article/require-nda-to-view"
>
- <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
</BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Manage your signed and one-click agreements.
</p>
</div>
- <ul className="flex items-center justify-between gap-4">
- {isTrial || isBusiness || isDatarooms || isDataroomsPlus ? (
- <Button variant="outline" onClick={handleCreateNew}>
- <FileTextIcon className="h-4 w-4" />
- Create agreement
- </Button>
- ) : (
- <AgreementsUpgradeButton />
- )}
- </ul>
+ {isTrial || isBusiness || isDatarooms || isDataroomsPlus ? (
+ <Button
+ onClick={handleCreateNew}
+ className="bg-gray-900 text-gray-50 hover:bg-gray-900/90"
+ >
+ Create agreement
+ </Button>
+ ) : (
+ <AgreementsUpgradeButton />
+ )}
</div>
+
{loading ? (
- <div className="flex items-center justify-center py-12">
- <div className="spinner" />
- <span className="ml-2 text-sm text-gray-500">
- Loading agreements...
- </span>
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
</div>
) : error ? (
- <div className="flex flex-col items-center justify-center space-y-4 py-12">
- <p className="text-center text-sm text-red-500">
- Failed to load agreements
- </p>
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <p className="text-sm text-red-500">Failed to load agreements</p>
<Button
variant="outline"
onClick={() => window.location.reload()}
@@ -137,36 +148,47 @@ export default function NdaAgreements() {
</Button>
</div>
) : activeAgreements.length !== 0 ? (
- <div>
- <ul>
- {displayedAgreements.map((agreement) => (
- <li key={agreement.id} className="mt-4">
- <AgreementCard
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Name
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Links
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Last updated
+ </TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {displayedAgreements.map((agreement) => (
+ <AgreementRow
+ key={agreement.id}
agreement={agreement}
onDelete={handleAgreementDeletion}
onEdit={handleAgreementEdit}
/>
- </li>
- ))}
- </ul>
+ ))}
+ </TableBody>
+ </Table>
</div>
) : (
- <div className="flex flex-col items-center justify-center space-y-4 py-12">
- <div className="rounded-full bg-gray-100 p-3">
- <PlusIcon className="h-6 w-6 text-gray-600" />
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
+ <FileTextIcon className="h-5 w-5" />
</div>
- <div className="text-center">
- <h3 className="font-medium">No NDA agreements yet</h3>
- <p className="mt-1 max-w-sm text-sm text-gray-500">
- Create your first NDA agreement to get started
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ No NDA agreements yet
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Create your first NDA agreement to get started.
</p>
</div>
- {(isTrial || isBusiness || isDatarooms || isDataroomsPlus) && (
- <Button variant="outline" onClick={handleCreateNew}>
- <FileTextIcon className="h-4 w-4" />
- Create NDA agreement
- </Button>
- )}
</div>
)}
</div>
diff --git a/pages/settings/domains.tsx b/pages/settings/domains.tsx
index 3ee8885c..ea8fb1ae 100644
--- a/pages/settings/domains.tsx
+++ b/pages/settings/domains.tsx
@@ -1,17 +1,25 @@
import { useState } from "react";
import { useTeam } from "@/context/team-context";
-import { CircleHelpIcon } from "lucide-react";
+import { Domain } from "@prisma/client";
+import { CircleHelpIcon, GlobeIcon } from "lucide-react";
import { mutate } from "swr";
import { usePlan } from "@/lib/swr/use-billing";
import { useDomains } from "@/lib/swr/use-domains";
import { AddDomainModal } from "@/components/domains/add-domain-modal";
-import DomainCard from "@/components/domains/domain-card";
+import DomainRow from "@/components/domains/domain-row";
import AppLayout from "@/components/layouts/app";
import { SettingsHeader } from "@/components/settings/settings-header";
import { Button } from "@/components/ui/button";
+import {
+ Table,
+ TableBody,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
import { BadgeTooltip } from "@/components/ui/tooltip";
export default function Domains() {
@@ -20,6 +28,7 @@ export default function Domains() {
const { isBusiness, isDatarooms } = usePlan();
const [open, setOpen] = useState<boolean>(false);
+ const [newlyAddedDomain, setNewlyAddedDomain] = useState<string | null>(null);
const handleDomainDeletion = (deletedDomain: string) => {
mutate(
@@ -29,7 +38,8 @@ export default function Domains() {
);
};
- const handleDomainAddition = (newDomain: string) => {
+ const handleDomainAddition = (newDomain: Domain) => {
+ setNewlyAddedDomain(newDomain?.slug ?? null);
mutate(
`/api/teams/${teamInfo?.currentTeam?.id}/domains`,
[...(domains || []), newDomain],
@@ -41,51 +51,82 @@ export default function Domains() {
<AppLayout>
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
<div className="space-y-1">
- <h3 className="text-2xl font-semibold tracking-tight text-foreground">
- Domains
- </h3>
- <p className="flx-row flex items-center gap-2 text-sm text-muted-foreground">
- Manage your custom domain for sharing documents and data rooms.
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Domains
+ </h2>
<BadgeTooltip
content="How to connect a custom domain to your link?"
key="verified"
linkText="Click here"
link="https://www.papermark.com/help/article/how-to-add-custom-domain-to-link"
>
- <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
</BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Manage your custom domain for sharing documents and data rooms.
</p>
</div>
- <ul className="flex items-center justify-between gap-4">
- <AddDomainModal
- open={open}
- setOpen={setOpen}
- onAddition={handleDomainAddition}
- >
- <Button>Add Domain</Button>
- </AddDomainModal>
- </ul>
+ <AddDomainModal
+ open={open}
+ setOpen={setOpen}
+ onAddition={handleDomainAddition}
+ >
+ <Button className="bg-gray-900 text-gray-50 hover:bg-gray-900/90">
+ Add Domain
+ </Button>
+ </AddDomainModal>
</div>
+
{domains && domains.length !== 0 ? (
- <div>
- <ul>
- {domains.map((domain, index) => (
- <li key={index} className="mt-4">
- <DomainCard
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Domain
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Status
+ </TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {domains.map((domain) => (
+ <DomainRow
+ key={domain.slug}
domain={domain.slug}
isDefault={domain.isDefault}
redirectUrl={domain.redirectUrl}
redirectsAllowed={isBusiness || isDatarooms}
+ defaultOpen={domain.slug === newlyAddedDomain}
onDelete={handleDomainDeletion}
/>
- </li>
- ))}
- </ul>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ ) : (
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
+ <GlobeIcon className="h-5 w-5" />
+ </div>
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ No custom domains yet
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Add a custom domain to share your documents and data rooms on
+ your own branded URL.
+ </p>
+ </div>
</div>
- ) : null}
+ )}
</div>
</main>
</AppLayout>
diff --git a/pages/settings/people.tsx b/pages/settings/people.tsx
index 83f9e10d..136e1280 100644
--- a/pages/settings/people.tsx
+++ b/pages/settings/people.tsx
@@ -4,6 +4,14 @@ import { useMemo, useState } from "react";
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
+import {
+ CircleHelpIcon,
+ MoreHorizontalIcon,
+ SendIcon,
+ UserCogIcon,
+ UserMinusIcon,
+ XCircleIcon,
+} from "lucide-react";
import { useSession } from "next-auth/react";
import { toast } from "sonner";
import { mutate } from "swr";
@@ -16,15 +24,18 @@ import useLimits from "@/lib/swr/use-limits";
import { useGetTeam } from "@/lib/swr/use-team";
import { useTeams } from "@/lib/swr/use-teams";
import { CustomUser, TeamRole } from "@/lib/types";
-import { cn } from "@/lib/utils";
+import { cn, generateGravatarHash } from "@/lib/utils";
import { AddSeatModal } from "@/components/billing/add-seat-modal";
import { UnlimitedPlanModal } from "@/components/billing/unlimited-plan-modal";
import AppLayout from "@/components/layouts/app";
import { SettingsHeader } from "@/components/settings/settings-header";
-import Folder from "@/components/shared/icons/folder";
-import MoreVertical from "@/components/shared/icons/more-vertical";
import { AddTeamMembers } from "@/components/teams/add-team-member-modal";
+import {
+ Avatar,
+ AvatarFallback,
+ AvatarImage,
+} from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import {
@@ -39,12 +50,19 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
-import { Skeleton } from "@/components/ui/skeleton";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
+import { BadgeTooltip } from "@/components/ui/tooltip";
import { UpgradeButton } from "@/components/ui/upgrade-button";
const ROLE_LABELS: Record<TeamRole, string> = {
@@ -90,22 +108,25 @@ export default function Billing() {
const router = useRouter();
- const documentCountsByUser = useMemo(() => {
- if (!team?.documents) return {};
+ const { datarooms } = useDataroomsSimple();
- const counts: Record<string, number> = {};
- team.documents.forEach((document) => {
- const ownerId = document.owner?.id;
- if (ownerId) {
- counts[ownerId] = (counts[ownerId] || 0) + 1;
- }
+ // Map of dataroom id -> display name, for rendering assignment tags.
+ const dataroomNameById = useMemo(() => {
+ const map: Record<string, string> = {};
+ (datarooms ?? []).forEach((dataroom) => {
+ map[dataroom.id] = dataroom.internalName || dataroom.name;
});
- return counts;
- }, [team]);
-
- const getUserDocumentCount = (userId: string) => {
- return documentCountsByUser[userId] || 0;
- };
+ return map;
+ }, [datarooms]);
+
+ // Map of user id -> assigned dataroom ids (for DATAROOM_MEMBERs).
+ const dataroomIdsByUser = useMemo(() => {
+ const map: Record<string, string[]> = {};
+ (team?.userDatarooms ?? []).forEach((ud) => {
+ (map[ud.userId] ??= []).push(ud.dataroomId);
+ });
+ return map;
+ }, [team?.userDatarooms]);
const isCurrentUser = (userId: string) => {
if ((session?.user as CustomUser)?.id === userId) {
@@ -115,10 +136,12 @@ export default function Billing() {
};
const isCurrentUserAdmin = () => {
- return team?.users.some(
- (user) =>
- user.role === "ADMIN" &&
- user.userId === (session?.user as CustomUser)?.id,
+ return (
+ team?.users.some(
+ (user) =>
+ user.role === "ADMIN" &&
+ user.userId === (session?.user as CustomUser)?.id,
+ ) ?? false
);
};
@@ -276,159 +299,176 @@ export default function Billing() {
<AppLayout>
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
+
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
<div className="space-y-1">
- <h3 className="text-2xl font-semibold tracking-tight text-foreground">
- Team Members
- </h3>
- <p className="text-sm text-muted-foreground">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Team Members
+ </h2>
+ <BadgeTooltip
+ content="Teammates that have access to this workspace."
+ className="max-w-80 text-left leading-5 text-gray-600"
+ >
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
+ </BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
Manage your team members.{" "}
{isDataroomsUnlimited ? (
- <span className="ml-1 font-medium">
+ <span className="font-medium text-gray-700 dark:text-gray-300">
Your team has unlimited seats 💫
</span>
) : (
- <UnlimitedPlanModal>
- <span className="cursor-pointer underline underline-offset-4 hover:text-foreground">
- Interested in unlimited team members?
- </span>
- </UnlimitedPlanModal>
+ <>
+ {limits?.users && limits.users !== Infinity ? (
+ <span>
+ {limits.usage?.users ?? 0}/{limits.users} seats used.{" "}
+ </span>
+ ) : null}
+ <UnlimitedPlanModal>
+ <span className="cursor-pointer underline underline-offset-4 hover:text-foreground">
+ Need unlimited seats?
+ </span>
+ </UnlimitedPlanModal>
+ </>
)}
</p>
</div>
- </div>
- <div>
- <div className="flex items-center justify-between gap-x-1 rounded-lg border border-border bg-secondary p-4 sm:p-10">
- <div className="flex flex-col space-y-1 sm:space-y-3">
- <h2 className="text-xl font-medium">Team</h2>
- <p className="text-sm text-secondary-foreground">
- Teammates that have access to this project.
- {!isDataroomsUnlimited &&
- limits?.users &&
- limits.users !== Infinity && (
- <span className="ml-1">
- ({limits.usage?.users ?? 0}/{limits.users} seats used)
- </span>
- )}
- </p>
- </div>
- {showUpgradePlanModal ? (
- <UpgradeButton
- text="Invite Members"
- clickedPlan={PlanEnum.Business}
- trigger="invite_team_members"
- highlightItem={["users"]}
- />
- ) : (
- <div className="flex items-center gap-2">
- {!isDataroomsUnlimited && (
- <AddSeatModal
- open={isAddSeatModalOpen}
- setOpen={setAddSeatModalOpen}
- >
- <Button variant="outline" className="whitespace-nowrap">
- Add Seat
- </Button>
- </AddSeatModal>
- )}
- {showInvite ? (
- <AddTeamMembers
- open={isTeamMemberInviteModalOpen}
- setOpen={setTeamMemberInviteModalOpen}
- >
- <Button>Invite</Button>
- </AddTeamMembers>
- ) : (
- <Button disabled title="Add a seat to invite more members">
+ {showUpgradePlanModal ? (
+ <UpgradeButton
+ text="Invite Members"
+ clickedPlan={PlanEnum.Business}
+ trigger="invite_team_members"
+ highlightItem={["users"]}
+ />
+ ) : (
+ <div className="flex items-center gap-2">
+ {!isDataroomsUnlimited && (
+ <AddSeatModal
+ open={isAddSeatModalOpen}
+ setOpen={setAddSeatModalOpen}
+ >
+ <Button variant="outline" className="whitespace-nowrap">
+ Add Seat
+ </Button>
+ </AddSeatModal>
+ )}
+ {showInvite ? (
+ <AddTeamMembers
+ open={isTeamMemberInviteModalOpen}
+ setOpen={setTeamMemberInviteModalOpen}
+ >
+ <Button className="bg-gray-900 text-gray-50 hover:bg-gray-900/90">
Invite
</Button>
- )}
- </div>
- )}
- </div>
+ </AddTeamMembers>
+ ) : (
+ <Button disabled title="Add a seat to invite more members">
+ Invite
+ </Button>
+ )}
+ </div>
+ )}
</div>
- <ul className="mt-6 divide-y rounded-lg border">
- {loading && (
- <div className="flex items-center justify-between px-10 py-4">
- <div className="flex items-center gap-12">
- <div className="space-y-2">
- <Skeleton className="h-6 w-36" />
- <Skeleton className="h-4 w-36" />
- </div>
- <Skeleton className="h-4 w-20" />
- </div>
- <div className="flex gap-12">
- <Skeleton className="h-6 w-14" />
- <Skeleton className="h-6 w-4" />
- </div>
+ {loading ? (
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
</div>
- )}
- {team?.users.map((member, index) => (
- <li
- className="flex items-center justify-between gap-12 overflow-auto px-10 py-4"
- key={index}
- >
- <div className="flex items-center gap-12">
- <div className="space-y-1">
- <h4 className="text-sm font-semibold">
- {member.user.name}
- </h4>
- <p className="text-xs text-muted-foreground">
- {member.user.email}
- </p>
- </div>
- <div className="text-sm">
- <div className="flex items-center gap-2">
- <Folder />
- <span className="text-nowrap text-xs text-foreground">
- {getUserDocumentCount(member.userId)}{" "}
- {getUserDocumentCount(member.userId) === 1
- ? "document"
- : "documents"}
- </span>
- </div>
- </div>
- </div>
- <div className="flex items-center gap-12">
- <div className="flex flex-col items-end gap-1">
- <span className="text-sm text-foreground">
- {formatRole(member.role)}
- </span>
- {member.status === "BLOCKED_TRIAL_EXPIRED" && (
- <span className="text-xs font-medium text-red-500">
- Blocked (Trial Expired)
- </span>
- )}
- </div>
- {leavingUserId === member.userId ? (
- <span className="text-xs">leaving...</span>
- ) : (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="h-8 w-8 p-0">
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- {isCurrentUser(member.userId) && (
- <DropdownMenuItem
- onClick={() =>
- removeTeammate(member.teamId, member.userId)
- }
- className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
- >
- Leave team
- </DropdownMenuItem>
- )}
- {isCurrentUserAdmin() &&
- !isCurrentUser(member.userId) ? (
- <>
- <DropdownMenuItem
- onClick={() =>
+ </div>
+ ) : (
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Member
+ </TableHead>
+ <TableHead className="text-right text-xs font-medium tracking-wide text-gray-500">
+ Role
+ </TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {team?.users.map((member) => {
+ return (
+ <TableRow
+ key={member.userId}
+ className="hover:bg-transparent"
+ >
+ <TableCell>
+ <div className="flex items-center gap-3">
+ <PersonAvatar
+ email={member.user.email}
+ name={member.user.name}
+ />
+ <div className="flex flex-col">
+ <span className="flex items-center gap-2 font-medium text-gray-900 dark:text-gray-100">
+ {member.user.name || member.user.email}
+ {isCurrentUser(member.userId) ? (
+ <span className="rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400">
+ You
+ </span>
+ ) : null}
+ </span>
+ <span className="text-xs text-gray-500">
+ {member.user.email}
+ </span>
+ </div>
+ </div>
+ </TableCell>
+ <TableCell className="text-right text-sm text-gray-700 dark:text-gray-300">
+ <div className="flex flex-col items-end gap-1">
+ <span>{formatRole(member.role)}</span>
+ {member.role === "DATAROOM_MEMBER" &&
+ (dataroomIdsByUser[member.userId]?.length ?? 0) >
+ 0 ? (
+ <div className="flex max-w-[240px] flex-wrap justify-end gap-1">
+ {dataroomIdsByUser[member.userId].map((id) => (
+ <span
+ key={id}
+ className="rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground"
+ title={dataroomNameById[id] || "Data room"}
+ >
+ {dataroomNameById[id] || "Data room"}
+ </span>
+ ))}
+ </div>
+ ) : null}
+ {member.status === "BLOCKED_TRIAL_EXPIRED" ? (
+ <span className="text-xs font-medium text-red-500">
+ Blocked (Trial Expired)
+ </span>
+ ) : (
+ <span className="inline-flex items-center gap-1.5 text-xs text-gray-500">
+ <span className="h-1.5 w-1.5 rounded-full bg-green-500" />
+ Active
+ </span>
+ )}
+ </div>
+ </TableCell>
+ <TableCell className="text-right">
+ {leavingUserId === member.userId ? (
+ <span className="text-xs text-gray-500">
+ leaving...
+ </span>
+ ) : (
+ <MemberRowMenu
+ canManage={
+ isCurrentUserAdmin() &&
+ !isCurrentUser(member.userId)
+ }
+ isCurrentUser={isCurrentUser(member.userId)}
+ onChangeRole={() =>
setRoleMember({
userId: member.userId,
teamId: member.teamId,
@@ -436,88 +476,60 @@ export default function Billing() {
role: member.role,
})
}
- className="hover:cursor-pointer"
- >
- Change role
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() =>
+ onRemove={() =>
+ removeTeammate(member.teamId, member.userId)
+ }
+ onLeave={() =>
removeTeammate(member.teamId, member.userId)
}
- className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
+ />
+ )}
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ {invitations?.map((invitation) => {
+ const isPending =
+ new Date(invitation.expires) >= new Date(Date.now());
+ return (
+ <TableRow
+ key={invitation.email}
+ className="hover:bg-transparent"
+ >
+ <TableCell>
+ <div className="flex items-center gap-3">
+ <PersonAvatar email={invitation.email} />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {invitation.email}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-right text-sm text-gray-700 dark:text-gray-300">
+ <div className="flex flex-col items-end gap-1">
+ <span className="text-gray-500">Invited</span>
+ <span
+ className="text-xs text-gray-500"
+ title={`Expires on ${new Date(
+ invitation.expires,
+ ).toLocaleString()}`}
>
- Remove teammate
- </DropdownMenuItem>
- </>
- ) : (
- <DropdownMenuItem
- disabled
- className="text-red-500 focus:bg-destructive focus:text-destructive-foreground"
- >
- Remove teammate
- </DropdownMenuItem>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </div>
- </li>
- ))}
- {invitations &&
- invitations.map((invitation, index) => (
- <li
- className="flex items-center justify-between px-10 py-4"
- key={index}
- >
- <div className="flex items-center gap-12">
- <div className="space-y-1">
- <h4 className="text-sm font-semibold">
- {invitation.email}
- </h4>
- <p className="text-xs text-muted-foreground">
- {invitation.email}
- </p>
- </div>
- </div>
- <div className="flex items-center gap-12">
- <span
- className="text-sm text-foreground"
- title={`Expires on ${new Date(
- invitation.expires,
- ).toLocaleString()}`}
- >
- {new Date(invitation.expires) >= new Date(Date.now())
- ? "Pending"
- : "Expired"}
- </span>
-
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="h-8 w-8 p-0">
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem
- onClick={() => resendInvitation(invitation)}
- className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
- >
- Resend
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => revokeInvitation(invitation)}
- className="text-red-500 hover:cursor-pointer focus:bg-destructive focus:text-destructive-foreground"
- >
- Revoke invitation
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </li>
- ))}
- </ul>
+ {isPending ? "Pending" : "Expired"}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-right">
+ <InvitationRowMenu
+ onResend={() => resendInvitation(invitation)}
+ onRevoke={() => revokeInvitation(invitation)}
+ />
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ </div>
+ )}
</div>
</main>
@@ -543,6 +555,147 @@ export default function Billing() {
);
}
+function PersonAvatar({
+ email,
+ name,
+}: {
+ email: string;
+ name?: string | null;
+}) {
+ const label = (name || email || "").trim();
+ return (
+ <Avatar className="h-8 w-8 shrink-0 border border-gray-200 dark:border-gray-800">
+ <AvatarImage
+ src={`https://gravatar.com/avatar/${generateGravatarHash(
+ email,
+ )}?s=80&d=404`}
+ alt={label}
+ />
+ <AvatarFallback className="bg-gray-100 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-300">
+ {label.charAt(0).toUpperCase()}
+ </AvatarFallback>
+ </Avatar>
+ );
+}
+
+function MemberRowMenu({
+ canManage,
+ isCurrentUser,
+ onChangeRole,
+ onRemove,
+ onLeave,
+}: {
+ canManage: boolean;
+ isCurrentUser: boolean;
+ onChangeRole: () => void;
+ onRemove: () => void;
+ onLeave: () => void;
+}) {
+ const [open, setOpen] = useState(false);
+
+ const handleSelect = (event: Event, action: () => void) => {
+ event.preventDefault();
+ setOpen(false);
+ action();
+ };
+
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ aria-label="Open member actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ {isCurrentUser ? (
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onLeave)}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <UserMinusIcon className="!h-4 !w-4" />
+ Leave team
+ </DropdownMenuItem>
+ ) : canManage ? (
+ <>
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onChangeRole)}
+ >
+ <UserCogIcon className="!h-4 !w-4 text-gray-500" />
+ Change role
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onRemove)}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <UserMinusIcon className="!h-4 !w-4" />
+ Remove member
+ </DropdownMenuItem>
+ </>
+ ) : (
+ <DropdownMenuItem
+ disabled
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <UserMinusIcon className="!h-4 !w-4" />
+ Remove member
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+function InvitationRowMenu({
+ onResend,
+ onRevoke,
+}: {
+ onResend: () => void;
+ onRevoke: () => void;
+}) {
+ const [open, setOpen] = useState(false);
+
+ const handleSelect = (event: Event, action: () => void) => {
+ event.preventDefault();
+ setOpen(false);
+ action();
+ };
+
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ aria-label="Open invitation actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ <DropdownMenuItem onSelect={(event) => handleSelect(event, onResend)}>
+ <SendIcon className="!h-4 !w-4 text-gray-500" />
+ Resend
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={(event) => handleSelect(event, onRevoke)}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <XCircleIcon className="!h-4 !w-4" />
+ Revoke invitation
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
function ChangeRoleDialog({
member,
currentAssignments,
diff --git a/pages/settings/presets/index.tsx b/pages/settings/presets/index.tsx
index 0508c601..82ddea64 100644
--- a/pages/settings/presets/index.tsx
+++ b/pages/settings/presets/index.tsx
@@ -1,4 +1,3 @@
-import Link from "next/link";
import { useRouter } from "next/router";
import { useState } from "react";
@@ -7,17 +6,24 @@ import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
import { LinkPreset } from "@prisma/client";
import { format } from "date-fns";
-import { CircleHelpIcon, CrownIcon, PlusIcon } from "lucide-react";
+import { CircleHelpIcon, SettingsIcon } from "lucide-react";
import useSWR from "swr";
import { usePlan } from "@/lib/swr/use-billing";
-import { fetcher, formatExpirationTime } from "@/lib/utils";
+import { fetcher } from "@/lib/utils";
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import AppLayout from "@/components/layouts/app";
import { SettingsHeader } from "@/components/settings/settings-header";
-import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
import { BadgeTooltip } from "@/components/ui/tooltip";
export default function Presets() {
@@ -43,27 +49,33 @@ export default function Presets() {
<AppLayout>
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="mb-4 flex items-center justify-between gap-x-2 md:mb-8 lg:mb-12">
- <div className="min-w-0 space-y-1">
- <h3 className="text-xl font-semibold tracking-tight text-foreground sm:text-2xl">
- Link Presets
- </h3>
- <p className="flex flex-row items-center gap-2 text-xs text-muted-foreground sm:text-sm">
- Configure and save presets for your links
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Link Presets
+ </h2>
<BadgeTooltip content="Create reusable link configurations that can be applied to new links">
- <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
</BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Configure and save presets for your links.
</p>
</div>
{isTrial || isBusiness || isDatarooms || isDataroomsPlus ? (
- <Button onClick={() => router.push("/settings/presets/new")} className="shrink-0 whitespace-nowrap">
- <PlusIcon className="mr-1.5 h-4 w-4" />
+ <Button
+ onClick={() => router.push("/settings/presets/new")}
+ className="shrink-0 whitespace-nowrap bg-gray-900 text-gray-50 hover:bg-gray-900/90"
+ >
Create Preset
</Button>
) : (
- <Button onClick={() => setShowUpgradeModal(true)} className="shrink-0 whitespace-nowrap text-xs sm:text-sm">
- <CrownIcon className="mr-1.5 h-4 w-4" />
+ <Button
+ onClick={() => setShowUpgradeModal(true)}
+ className="shrink-0 whitespace-nowrap bg-gray-900 text-gray-50 hover:bg-gray-900/90"
+ >
Upgrade
</Button>
)}
@@ -71,62 +83,68 @@ export default function Presets() {
{/* Presets List */}
{isLoading ? (
- <div className="flex items-center justify-center py-12">
- <p className="text-muted-foreground">Loading presets...</p>
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
</div>
) : !presets || presets.length === 0 ? (
- <div className="flex flex-col items-center justify-center space-y-4 py-12">
- <div className="rounded-full bg-gray-100 p-3">
- <PlusIcon className="h-6 w-6 text-gray-600" />
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
+ <SettingsIcon className="h-5 w-5" />
</div>
- <div className="text-center">
- <h3 className="font-medium">No presets configured</h3>
- <p className="mt-1 max-w-sm text-sm text-gray-500">
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ No presets configured
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
Create link presets to quickly apply your preferred settings
when creating links.
</p>
</div>
- {isTrial || isBusiness || isDatarooms || isDataroomsPlus ? (
- <Button
- variant="outline"
- onClick={() => router.push("/settings/presets/new")}
- >
- Create your first preset
- </Button>
- ) : (
- <Button
- variant="outline"
- onClick={() => setShowUpgradeModal(true)}
- >
- Upgrade to create presets
- </Button>
- )}
</div>
) : (
- <div className="grid grid-cols-1 gap-3">
- {presets.map((preset) => (
- <Link
- key={preset.id}
- href={`/settings/presets/${preset.id}`}
- className="rounded-xl border border-gray-200 bg-white p-4 transition-[filter] hover:bg-gray-50 dark:border-gray-400 dark:bg-secondary dark:hover:bg-gray-800 sm:p-5"
- >
- <div className="flex items-center justify-between">
- <div>
- <div className="flex items-center gap-2">
- <span className="font-semibold">{preset.name}</span>
- </div>
- <div className="mt-1 flex items-center gap-4 text-sm text-muted-foreground">
- <div className="flex items-center gap-1">
- <span>
- Created:{" "}
- {format(new Date(preset.createdAt), "MMM d, yyyy")}
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Name
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Created
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {presets.map((preset) => (
+ <TableRow
+ key={preset.id}
+ className="cursor-pointer"
+ onClick={() =>
+ router.push(`/settings/presets/${preset.id}`)
+ }
+ >
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <SettingsIcon className="h-4 w-4 text-gray-400" />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {preset.name}
</span>
</div>
- </div>
- </div>
- </div>
- </Link>
- ))}
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {format(new Date(preset.createdAt), "MMM d, yyyy")}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</div>
)}
</div>
diff --git a/pages/settings/tags.tsx b/pages/settings/tags.tsx
index f8e21a81..8853ddaa 100644
--- a/pages/settings/tags.tsx
+++ b/pages/settings/tags.tsx
@@ -1,13 +1,13 @@
import { useRouter } from "next/router";
-import { Fragment, useEffect, useState } from "react";
+import { useEffect, useState } from "react";
import { useTeam } from "@/context/team-context";
import {
+ CircleHelpIcon,
InfoIcon,
MoreHorizontalIcon,
Settings2Icon,
- Tag,
TagIcon,
TrashIcon,
} from "lucide-react";
@@ -16,6 +16,7 @@ import { z } from "zod";
import { useTags } from "@/lib/swr/use-tags";
import { TagColorProps, tagColors } from "@/lib/types";
+import { cn } from "@/lib/utils";
import { Pagination } from "@/components/documents/pagination";
import AppLayout from "@/components/layouts/app";
@@ -31,11 +32,8 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import { Skeleton } from "@/components/ui/skeleton";
import {
Table,
TableBody,
@@ -188,20 +186,32 @@ export default function TagSetting() {
setTagForm(defaultValue);
};
+ const hasTags = (tagCount ?? 0) > 0;
+ const isSearching = !!searchQuery;
+
return (
<AppLayout>
- <main className="mx-2 mb-10 mt-4 space-y-8 px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
+ <main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="space-y-1">
- <h3 className="text-2xl font-semibold">Tags</h3>
- <p className="flex items-center gap-2 text-sm text-muted-foreground">
- Manage and categorize your tags here.
- </p>
- </div>
- <div className="my-4 flex items-center justify-between">
- <SearchBoxPersisted loading={isValidating} inputClassName="h-10" />
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 dark:border-gray-800 sm:flex-row sm:items-center sm:p-6">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Tags
+ </h2>
+ <BadgeTooltip
+ content="Organize and categorize your links and documents with tags."
+ className="max-w-80 text-left leading-5 text-gray-600"
+ >
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
+ </BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Manage and categorize your tags here.
+ </p>
+ </div>
<AddTagsModal
open={open}
setMenuOpen={setMenuOpen}
@@ -210,150 +220,178 @@ export default function TagSetting() {
handleSubmit={handleSubmit}
tagCount={tagCount}
>
- <Button>Create Tag</Button>
+ <Button className="bg-gray-900 text-gray-50 hover:bg-gray-900/90">
+ Create Tag
+ </Button>
</AddTagsModal>
</div>
- <div className="rounded-md border">
- <Table>
- <TableHeader>
- <TableRow className="*:whitespace-nowrap *:font-medium hover:bg-transparent">
- <TableHead>Tag Name</TableHead>
- <TableHead></TableHead>
- <TableHead className="text-center sm:text-right">
- Action
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {tagCount === 0 && !loadingTags && (
- <TableRow>
- <TableCell colSpan={5}>
- <div className="flex h-40 w-full items-center justify-center">
- <p>No Tags Available</p>
- </div>
- </TableCell>
- </TableRow>
- )}
- {availableTags && !loadingTags ? (
- availableTags.map((tag) => {
- return (
- <Fragment key={tag.id}>
- <TableRow className="group/row">
- {/* Name */}
- <TableCell>
- <div className="flex items-center overflow-visible sm:space-x-3">
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <TagIcon
- size={24}
- className={`rounded-sm border p-1 ${COLORS_LIST.find((c) => c.color === tag.color)?.css ?? ""}`}
- />
- <p>{tag.name}</p>
- {!!tag.description && (
- <BadgeTooltip
- content={tag.description}
- key="tag_tooltip"
- >
- <InfoIcon className="h-4 w-4 shrink-0 cursor-pointer text-muted-foreground hover:text-foreground" />
- </BadgeTooltip>
- )}
- </div>
- </div>
- </div>
- </TableCell>
- {/* Link Count */}
- <TableCell className="text-center text-sm text-muted-foreground sm:text-right">
- <Button variant="outline" size="sm">
- {tag._count?.items || 0} links
- </Button>
- </TableCell>
- {/* Actions */}
- <TableCell className="text-center sm:text-right">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- className="h-8 w-8 p-0 group-hover/row:ring-1 group-hover/row:ring-gray-200 group-hover/row:dark:ring-gray-700"
- >
- <span className="sr-only">Open menu</span>
- <MoreHorizontalIcon className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <div className="border-b border-gray-200 p-5 dark:border-gray-800 sm:p-6">
+ <SearchBoxPersisted loading={isValidating} inputClassName="h-10" />
+ </div>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- setTagForm({
- color: tag.color as TagColorProps,
- name: tag.name,
- description: tag.description,
- id: tag.id,
- loading: false,
- });
- setOpen(true);
- }}
- >
- <Settings2Icon className="mr-2 h-4 w-4" />
- Edit tag
- </DropdownMenuItem>
- <DropdownMenuItem
- className="text-destructive transition-colors duration-200 focus:bg-destructive focus:text-destructive-foreground"
- onClick={(e) => {
- e.stopPropagation();
- handleDeleteTag(tag.id);
- }}
- >
- <TrashIcon className="mr-2 h-4 w-4" />
- Delete tag
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- </Fragment>
- );
- })
- ) : (
- <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>
+ {loadingTags ? (
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
+ </div>
+ ) : !hasTags ? (
+ <EmptyState isSearching={isSearching} />
+ ) : (
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Name
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Links
+ </TableHead>
+ <TableHead className="w-10" />
</TableRow>
- )}
- </TableBody>
- </Table>
- </div>
- {/* Pagination Controls */}
- {tagCount !== undefined && (
- <Pagination
- currentPage={currentPage}
- pageSize={pageSize}
- totalItems={tagCount}
- totalShownItems={availableTags?.length || 0}
- totalPages={Math.ceil(tagCount / pageSize)}
- onPageChange={setCurrentPage}
- onPageSizeChange={(size: number) => {
- setPageSize(size);
- setCurrentPage(1);
- }}
- itemName="tags"
- />
+ </TableHeader>
+ <TableBody>
+ {availableTags?.map((tag) => (
+ <TableRow key={tag.id} className="group/row">
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <TagIcon
+ size={24}
+ className={cn(
+ "shrink-0 rounded-sm border p-1",
+ COLORS_LIST.find((c) => c.color === tag.color)
+ ?.css ?? "",
+ )}
+ />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {tag.name}
+ </span>
+ {!!tag.description && (
+ <BadgeTooltip
+ content={tag.description}
+ key="tag_tooltip"
+ >
+ <InfoIcon className="h-4 w-4 shrink-0 cursor-pointer text-muted-foreground hover:text-foreground" />
+ </BadgeTooltip>
+ )}
+ </div>
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {tag._count?.items || 0} links
+ </TableCell>
+ <TableCell
+ className="text-right"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <RowMenu
+ onEdit={() => {
+ setTagForm({
+ color: tag.color as TagColorProps,
+ name: tag.name,
+ description: tag.description,
+ id: tag.id,
+ loading: false,
+ });
+ setOpen(true);
+ }}
+ onDelete={() => handleDeleteTag(tag.id)}
+ />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
)}
</div>
+
+ {/* Pagination Controls */}
+ {hasTags && (
+ <Pagination
+ currentPage={currentPage}
+ pageSize={pageSize}
+ totalItems={tagCount ?? 0}
+ totalShownItems={availableTags?.length || 0}
+ totalPages={Math.ceil((tagCount ?? 0) / pageSize)}
+ onPageChange={setCurrentPage}
+ onPageSizeChange={(size: number) => {
+ setPageSize(size);
+ setCurrentPage(1);
+ }}
+ itemName="tags"
+ />
+ )}
</main>
</AppLayout>
);
-}
\ No newline at end of file
+}
+
+function EmptyState({ isSearching }: { isSearching: boolean }) {
+ return (
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
+ <TagIcon className="h-5 w-5" />
+ </div>
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ {isSearching ? "No tags found" : "No tags yet"}
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ {isSearching
+ ? "Try a different search term to find your tags."
+ : "Create your first tag to organize your links and documents."}
+ </p>
+ </div>
+ </div>
+ );
+}
+
+function RowMenu({
+ onEdit,
+ onDelete,
+}: {
+ onEdit: () => void;
+ onDelete: () => void;
+}) {
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ aria-label="Open tag actions"
+ >
+ <MoreHorizontalIcon className="!h-4 !w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-36">
+ <DropdownMenuItem
+ onSelect={() => {
+ // Defer until the menu has fully closed so opening the edit
+ // dialog doesn't get cancelled by the menu's focus/pointer events.
+ setTimeout(() => onEdit(), 0);
+ }}
+ >
+ <Settings2Icon className="!h-4 !w-4 text-gray-500" />
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => onDelete()}
+ className="text-red-600 focus:bg-red-50 focus:text-red-700 dark:focus:bg-red-900/20"
+ >
+ <TrashIcon className="!h-4 !w-4" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/pages/settings/tokens.tsx b/pages/settings/tokens.tsx
index 85cbdcc5..c86a55ca 100644
--- a/pages/settings/tokens.tsx
+++ b/pages/settings/tokens.tsx
@@ -1,21 +1,17 @@
-import { useRouter } from "next/router";
-
-import { useEffect, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import { useTeam } from "@/context/team-context";
import { format } from "date-fns";
import {
CircleHelpIcon,
+ ExternalLinkIcon,
KeyRoundIcon,
MoreHorizontalIcon,
PencilIcon,
TrashIcon,
} from "lucide-react";
-import { toast } from "sonner";
import useSWR from "swr";
-import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
-import { usePlan } from "@/lib/swr/use-billing";
import { cn, fetcher, timeAgo } from "@/lib/utils";
import AppLayout from "@/components/layouts/app";
@@ -62,21 +58,6 @@ interface Token {
export default function TokenSettings() {
const teamInfo = useTeam();
const teamId = teamInfo?.currentTeam?.id;
- const router = useRouter();
-
- const { isDatarooms, isTrial, loading: planLoading } = usePlan();
- const { features, isLoading: featuresLoading } = useFeatureFlags();
- const hasTokensAccess = isDatarooms || isTrial || !!features?.tokens;
-
- useEffect(() => {
- // `planLoading` is only meaningful once we have a teamId. Wait for the
- // feature flags too so we don't redirect a flag-enabled team prematurely.
- if (!teamId || planLoading || featuresLoading) return;
- if (!hasTokensAccess) {
- router.push("/settings/general");
- toast.error("This feature requires a Data Rooms plan or higher");
- }
- }, [teamId, planLoading, featuresLoading, hasTokensAccess, router]);
const {
data: tokens,
@@ -147,134 +128,148 @@ export default function TokenSettings() {
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
- <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
- <div className="space-y-1">
+ {
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 dark:border-gray-800 sm:flex-row sm:items-center sm:p-6">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Secret keys
+ </h2>
+ <BadgeTooltip
+ content="These API keys allow other apps to access your workspace. Use them with caution — do not share your API key with others, or expose it in the browser or other client-side code."
+ className="max-w-80 text-left leading-5 text-gray-600"
+ >
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
+ </BadgeTooltip>
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Create scoped API keys for your apps, automation, and MCP
+ clients.
+ </p>
+ </div>
<div className="flex items-center gap-2">
- <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
- Secret keys
- </h2>
- <BadgeTooltip
- content="These API keys allow other apps to access your workspace. Use them with caution — do not share your API key with others, or expose it in the browser or other client-side code."
- className="max-w-80 text-left leading-5 text-gray-600"
+ <Button asChild variant="ghost">
+ <a
+ href="https://www.papermark.com/docs"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ Documentation
+ <ExternalLinkIcon className="!h-3.5 !w-3.5" />
+ </a>
+ </Button>
+ <Button
+ type="button"
+ onClick={() => setShowCreateTokenModal(true)}
+ className="bg-gray-900 text-gray-50 hover:bg-gray-900/90"
>
- <CircleHelpIcon className="h-4 w-4 text-gray-400" />
- </BadgeTooltip>
+ Create API key
+ </Button>
</div>
- <p className="text-sm text-gray-500 dark:text-gray-400">
- Create scoped API keys for your apps, automation, and MCP
- clients.
- </p>
</div>
- <Button
- type="button"
- onClick={() => setShowCreateTokenModal(true)}
- className="bg-gray-900 text-gray-50 hover:bg-gray-900/90"
- >
- Create API key
- </Button>
- </div>
- {isLoading ? (
- <div className="p-6">
- <div className="space-y-2">
- {Array.from({ length: 3 }).map((_, i) => (
- <div
- key={i}
- className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
- />
- ))}
+ {isLoading ? (
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
</div>
- </div>
- ) : !hasTokens ? (
- <EmptyState onCreate={() => setShowCreateTokenModal(true)} />
- ) : (
- <div className="overflow-x-auto">
- <Table>
- <TableHeader>
- <TableRow className="hover:bg-transparent">
- <TableHead className="text-xs font-medium uppercase tracking-wide text-gray-500">
- Name
- </TableHead>
- <TableHead className="text-xs font-medium uppercase tracking-wide text-gray-500">
- Permissions
- </TableHead>
- <TableHead className="text-xs font-medium uppercase tracking-wide text-gray-500">
- Created
- </TableHead>
- <TableHead className="text-xs font-medium uppercase tracking-wide text-gray-500">
- Key
- </TableHead>
- <TableHead className="text-xs font-medium uppercase tracking-wide text-gray-500">
- Last used
- </TableHead>
- <TableHead className="w-10" />
- </TableRow>
- </TableHeader>
- <TableBody>
- {tokens?.map((token) => (
- <TableRow
- key={token.id}
- className="cursor-pointer"
- onClick={() => openEdit(token)}
- >
- <TableCell>
- <div className="flex items-center gap-2">
- <KeyRoundIcon className="h-4 w-4 text-gray-400" />
+ ) : !hasTokens ? (
+ <EmptyState />
+ ) : (
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Name
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Permissions
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Created
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Key
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Last used
+ </TableHead>
+ <TableHead className="w-10" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {tokens?.map((token) => (
+ <TableRow
+ key={token.id}
+ className="cursor-pointer"
+ onClick={() => openEdit(token)}
+ >
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <KeyRoundIcon className="h-4 w-4 text-gray-400" />
+ <div className="flex flex-col">
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {token.name}
+ </span>
+ <span className="text-xs text-gray-500">
+ {TOKEN_TYPE_LABELS[token.subjectType]}
+ </span>
+ </div>
+ </div>
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {scopesToPermissionLabel(token.scopes)}
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
<div className="flex flex-col">
- <span className="font-medium text-gray-900 dark:text-gray-100">
- {token.name}
+ <span>
+ {format(new Date(token.createdAt), "MMM d, yyyy")}
</span>
<span className="text-xs text-gray-500">
- {TOKEN_TYPE_LABELS[token.subjectType]}
+ by{" "}
+ {token.user.name ??
+ token.user.email ??
+ "Unknown user"}
</span>
</div>
- </div>
- </TableCell>
- <TableCell className="text-sm text-gray-700 dark:text-gray-300">
- {scopesToPermissionLabel(token.scopes)}
- </TableCell>
- <TableCell className="text-sm text-gray-700 dark:text-gray-300">
- <div className="flex flex-col">
- <span>
- {format(new Date(token.createdAt), "MMM d, yyyy")}
- </span>
- <span className="text-xs text-gray-500">
- by{" "}
- {token.user.name ??
- token.user.email ??
- "Unknown user"}
- </span>
- </div>
- </TableCell>
- <TableCell className="font-mono text-sm text-gray-700 dark:text-gray-300">
- {token.partialKey}
- </TableCell>
- <TableCell className="text-sm text-gray-700 dark:text-gray-300">
- {token.lastUsed ? timeAgo(token.lastUsed) : "Never"}
- </TableCell>
- <TableCell
- className={cn("text-right")}
- onClick={(event) => event.stopPropagation()}
- >
- <RowMenu
- onEdit={() => openEdit(token)}
- onDelete={() => openDelete(token)}
- />
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </div>
- )}
- </div>
+ </TableCell>
+ <TableCell className="font-mono text-sm text-gray-700 dark:text-gray-300">
+ {token.partialKey}
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {token.lastUsed ? timeAgo(token.lastUsed) : "Never"}
+ </TableCell>
+ <TableCell
+ className={cn("text-right")}
+ onClick={(event) => event.stopPropagation()}
+ >
+ <RowMenu
+ onEdit={() => openEdit(token)}
+ onDelete={() => openDelete(token)}
+ />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ )}
+ </div>
+ }
</main>
</AppLayout>
);
}
-function EmptyState({ onCreate }: { onCreate: () => void }) {
+function EmptyState() {
return (
<div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
<div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
@@ -288,13 +283,6 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
Create your first API key to use the Papermark API.
</p>
</div>
- <Button
- type="button"
- onClick={onCreate}
- className="bg-gray-900 text-gray-50 hover:bg-gray-900/90"
- >
- Create API key
- </Button>
</div>
);
}
diff --git a/pages/settings/upgrade.tsx b/pages/settings/upgrade.tsx
index e071e781..e609bb05 100644
--- a/pages/settings/upgrade.tsx
+++ b/pages/settings/upgrade.tsx
@@ -134,7 +134,19 @@ export default function UpgradePage() {
const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");
const [selectedPlan, setSelectedPlan] = useState<string | null>(null);
const teamInfo = useTeam();
- const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();
+ const { plan: teamPlan, trial, isTrial, isCustomer, isOldAccount } =
+ usePlan();
+
+ const canStartDataRoomTrial =
+ !isTrial && (teamPlan === "free" || teamPlan === "pro");
+
+ const handleStartDataRoomTrial = () => {
+ analytics.capture("Data Room Trial Button Clicked", {
+ source: "upgrade_page",
+ teamId: teamInfo?.currentTeam?.id,
+ });
+ router.push("/welcome?type=dataroom-trial");
+ };
const analytics = useAnalytics();
// Determine initial view based on query params or default to datarooms
@@ -165,9 +177,20 @@ export default function UpgradePage() {
return (
<div className="min-h-screen bg-gray-50 p-8 dark:bg-gray-900">
- <h1 className="mb-8 text-center text-3xl font-bold">
- Select best plan for your business
- </h1>
+ <div className="relative mb-8 flex flex-col items-center gap-3 sm:block">
+ <h1 className="text-center text-3xl font-bold">
+ Select best plan for your business
+ </h1>
+ {canStartDataRoomTrial && (
+ <Button
+ size="sm"
+ className="bg-[#fb7a00] text-white hover:bg-[#fb7a00]/90 sm:absolute sm:right-0 sm:top-1/2 sm:-translate-y-1/2"
+ onClick={handleStartDataRoomTrial}
+ >
+ Start 7-day trial
+ </Button>
+ )}
+ </div>
<div className="mb-8 flex items-center justify-center">
<span className="mr-2 text-sm">Monthly</span>
diff --git a/pages/settings/webhooks/index.tsx b/pages/settings/webhooks/index.tsx
index 884e1e73..73aca653 100644
--- a/pages/settings/webhooks/index.tsx
+++ b/pages/settings/webhooks/index.tsx
@@ -1,7 +1,11 @@
import Link from "next/link";
+import { useRouter } from "next/router";
+
+import { useMemo } from "react";
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
+import { format } from "date-fns";
import { CircleHelpIcon, CrownIcon, WebhookIcon } from "lucide-react";
import useSWR from "swr";
@@ -12,6 +16,14 @@ import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import AppLayout from "@/components/layouts/app";
import { SettingsHeader } from "@/components/settings/settings-header";
import { Button } from "@/components/ui/button";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/components/ui/table";
import { BadgeTooltip } from "@/components/ui/tooltip";
interface Webhook {
@@ -22,93 +34,169 @@ interface Webhook {
}
export default function WebhookSettings() {
+ const router = useRouter();
const teamInfo = useTeam();
- const { isFree, isPro, isTrial } = usePlan();
const teamId = teamInfo?.currentTeam?.id;
- const { data: webhooks } = useSWR<Webhook[]>(
+ const { isFree, isPro, isTrial } = usePlan();
+ const showUpgrade = (isFree || isPro) && !isTrial;
+
+ const {
+ data: webhooks,
+ isLoading,
+ error,
+ } = useSWR<Webhook[]>(
teamId ? `/api/teams/${teamId}/webhooks` : null,
fetcher,
);
+ const hasWebhooks = useMemo(() => (webhooks?.length ?? 0) > 0, [webhooks]);
+
return (
<AppLayout>
<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<SettingsHeader />
- <div>
- <div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
- <div className="space-y-1">
- <h3 className="flex items-center gap-2 text-2xl font-semibold tracking-tight text-foreground">
- Webhooks{" "}
- {(isFree || isPro) && !isTrial ? (
- <UpgradePlanModal
- clickedPlan={PlanEnum.Business}
- trigger="create_webhook"
- highlightItem={["webhooks"]}
- >
- <span className="cursor-pointer">
- <CrownIcon className="h-4 w-4 text-muted-foreground hover:text-foreground" />
- </span>
- </UpgradePlanModal>
- ) : null}
- </h3>
- <p className="flex flex-row items-center gap-2 text-sm text-muted-foreground">
- Send data to external services when events happen in Papermark
- <BadgeTooltip content="Send data to external services when events happen in Papermark">
- <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
- </BadgeTooltip>
- </p>
- </div>
- <Link href="/settings/webhooks/new">
- <Button>Create Webhook</Button>
- </Link>
- </div>
- {/* Webhooks List */}
- {!webhooks || webhooks.length === 0 ? (
- <div className="flex flex-col items-center justify-center space-y-4 py-12">
- <div className="rounded-full bg-gray-100 p-3">
- <WebhookIcon className="h-6 w-6 text-gray-600" />
- </div>
- <div className="text-center">
- <h3 className="font-medium">No webhooks configured</h3>
- <p className="mt-1 max-w-sm text-sm text-gray-500">
- Webhooks allow you to receive HTTP requests whenever specific
- events occur in your account.
+ {
+ <div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900">
+ <div className="flex flex-col items-start justify-between gap-3 border-b border-gray-200 p-5 sm:flex-row sm:items-center sm:p-6 dark:border-gray-800">
+ <div className="space-y-1">
+ <div className="flex items-center gap-2">
+ <h2 className="text-base font-semibold text-gray-900 dark:text-gray-100">
+ Webhooks
+ </h2>
+ {showUpgrade ? (
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.Business}
+ trigger="create_webhook"
+ highlightItem={["webhooks"]}
+ >
+ <span className="cursor-pointer">
+ <CrownIcon className="h-4 w-4 text-muted-foreground hover:text-foreground" />
+ </span>
+ </UpgradePlanModal>
+ ) : (
+ <BadgeTooltip
+ content="Send data to external services when events happen in Papermark"
+ className="max-w-80 text-left leading-5 text-gray-600"
+ >
+ <CircleHelpIcon className="h-4 w-4 text-gray-400" />
+ </BadgeTooltip>
+ )}
+ </div>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Send data to external services when events happen in
+ Papermark.
</p>
</div>
+ <Link href="/settings/webhooks/new">
+ <Button className="bg-gray-900 text-gray-50 hover:bg-gray-900/90">
+ Create Webhook
+ </Button>
+ </Link>
</div>
- ) : (
- <div className="grid grid-cols-1 gap-3">
- {webhooks.map((webhook) => (
- <Link
- key={webhook.id}
- href={`/settings/webhooks/${webhook.id}`}
- className="rounded-xl border border-gray-200 bg-white p-4 transition-[filter] dark:border-gray-400 dark:bg-secondary sm:p-5"
- >
- <div className="flex items-center gap-x-3">
- {/* <div className="rounded-md border border-gray-200 bg-gradient-to-t from-gray-100 p-2.5">
- <Avatar className="size-6">
- <AvatarFallback>
- {webhook.name.slice(0, 2).toUpperCase()}
- </AvatarFallback>
- </Avatar>
- </div> */}
- <div>
- <div className="flex items-center gap-1">
- <span className="font-semibold">{webhook.name}</span>
- </div>
- <div className="flex items-center gap-1 text-sm text-muted-foreground">
- {webhook.url}
- </div>
- </div>
- </div>
- </Link>
- ))}
- </div>
- )}
- </div>
+
+ {isLoading ? (
+ <div className="p-6">
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-gray-100 dark:bg-gray-800"
+ />
+ ))}
+ </div>
+ </div>
+ ) : error ? (
+ <ErrorState />
+ ) : !hasWebhooks ? (
+ <EmptyState />
+ ) : (
+ <div className="overflow-x-auto">
+ <Table>
+ <TableHeader>
+ <TableRow className="hover:bg-transparent">
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Name
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ URL
+ </TableHead>
+ <TableHead className="text-xs font-medium tracking-wide text-gray-500">
+ Created
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {webhooks?.map((webhook) => (
+ <TableRow
+ key={webhook.id}
+ className="cursor-pointer"
+ onClick={() =>
+ router.push(`/settings/webhooks/${webhook.id}`)
+ }
+ >
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <WebhookIcon className="h-4 w-4 text-gray-400" />
+ <span className="font-medium text-gray-900 dark:text-gray-100">
+ {webhook.name}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {webhook.url}
+ </TableCell>
+ <TableCell className="text-sm text-gray-700 dark:text-gray-300">
+ {format(new Date(webhook.createdAt), "MMM d, yyyy")}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ )}
+ </div>
+ }
</main>
</AppLayout>
);
-}
\ No newline at end of file
+}
+
+function ErrorState() {
+ return (
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-red-200 bg-red-50 text-red-500 dark:border-red-900 dark:bg-red-950">
+ <WebhookIcon className="h-5 w-5" />
+ </div>
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ Failed to load webhooks
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Something went wrong while loading your webhooks. Please refresh the
+ page or try again later.
+ </p>
+ </div>
+ </div>
+ );
+}
+
+function EmptyState() {
+ return (
+ <div className="flex flex-col items-center justify-center gap-3 px-6 py-16 text-center">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full border border-gray-200 bg-gray-50 text-gray-500 dark:border-gray-700 dark:bg-gray-800">
+ <WebhookIcon className="h-5 w-5" />
+ </div>
+ <div className="space-y-1">
+ <p className="text-sm font-medium text-gray-900 dark:text-gray-100">
+ No webhooks configured
+ </p>
+ <p className="text-sm text-gray-500 dark:text-gray-400">
+ Webhooks allow you to receive HTTP requests whenever specific events
+ occur in your account.
+ </p>
+ </div>
+ </div>
+ );
+}