Skip to content

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

feat: add new upgrade modal

Marc Seitzf3180de63e62
diff --git a/components/analytics/documents-table.tsx b/components/analytics/documents-table.tsx
index c4b93f3e..05401a7f 100644
--- a/components/analytics/documents-table.tsx
+++ b/components/analytics/documents-table.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import {
ColumnDef,
SortingState,
@@ -39,7 +40,6 @@ import { usePlan } from "@/lib/swr/use-billing";
import { fetcher, timeAgo } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
interface Document {
diff --git a/components/analytics/links-table.tsx b/components/analytics/links-table.tsx
index f25b9712..09b718fb 100644
--- a/components/analytics/links-table.tsx
+++ b/components/analytics/links-table.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import {
ColumnDef,
SortingState,
@@ -43,7 +44,6 @@ import { fetcher } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
interface Link {
id: string;
diff --git a/components/analytics/time-range-select.tsx b/components/analytics/time-range-select.tsx
index f89d4abe..f343dd3f 100644
--- a/components/analytics/time-range-select.tsx
+++ b/components/analytics/time-range-select.tsx
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
+import { PlanEnum } from "@/ee/stripe/constants";
import { differenceInDays, format, startOfDay, subDays } from "date-fns";
import { CalendarIcon, ChevronDown, CrownIcon } from "lucide-react";
import { DateRange } from "react-day-picker";
@@ -15,7 +16,6 @@ import {
import { cn } from "@/lib/utils";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
const TIME_RANGES = [
diff --git a/components/analytics/views-table.tsx b/components/analytics/views-table.tsx
index 1e5e4038..f76baed3 100644
--- a/components/analytics/views-table.tsx
+++ b/components/analytics/views-table.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { useMemo, useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import {
ColumnDef,
SortingState,
@@ -61,7 +62,6 @@ import { cn, durationFormat, fetcher, timeAgo } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
interface View {
id: string;
diff --git a/components/analytics/visitors-table.tsx b/components/analytics/visitors-table.tsx
index f51f62d8..b09c65a0 100644
--- a/components/analytics/visitors-table.tsx
+++ b/components/analytics/visitors-table.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import {
ColumnDef,
SortingState,
@@ -42,7 +43,6 @@ import { usePlan } from "@/lib/swr/use-billing";
import { durationFormat, fetcher, timeAgo } from "@/lib/utils";
import { downloadCSV } from "@/lib/utils/csv";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
interface Visitor {
diff --git a/components/billing/pro-banner.tsx b/components/billing/pro-banner.tsx
index 4e781fce..faf9578c 100644
--- a/components/billing/pro-banner.tsx
+++ b/components/billing/pro-banner.tsx
@@ -1,12 +1,13 @@
import { Dispatch, SetStateAction } from "react";
+import { PlanEnum } from "@/ee/stripe/constants";
import Cookies from "js-cookie";
import { usePlausible } from "next-plausible";
import X from "@/components/shared/icons/x";
import { Button } from "@/components/ui/button";
-import { PlanEnum, UpgradePlanModal } from "./upgrade-plan-modal";
+import { UpgradePlanModal } from "./upgrade-plan-modal";
export default function ProBanner({
setShowProBanner,
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsx
index fc88309f..6e44f5fb 100644
--- a/components/billing/upgrade-plan-modal.tsx
+++ b/components/billing/upgrade-plan-modal.tsx
@@ -6,13 +6,9 @@ import React from "react";
import { useTeam } from "@/context/team-context";
import { getStripe } from "@/ee/stripe/client";
+import { Feature, PlanEnum, getPlanFeatures } from "@/ee/stripe/constants";
import { PLANS } from "@/ee/stripe/utils";
-import {
- CheckIcon,
- MinusCircleIcon,
- PlusCircleIcon,
- Users2Icon,
-} from "lucide-react";
+import { CheckIcon, Users2Icon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
@@ -26,42 +22,80 @@ import {
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
-import { capitalize } from "@/lib/utils";
+import { capitalize, cn } from "@/lib/utils";
+
+// Feature rendering component
+const FeatureItem = ({ feature }: { feature: Feature }) => {
+ const baseClasses = `flex items-center ${feature.isHighlighted ? "bg-orange-50 -mx-6 px-6 py-2 -my-1 font-bold rounded-md dark:bg-orange-900/20" : ""}`;
+
+ if (feature.isUsers) {
+ return (
+ <div className={cn("justify-between gap-x-8", baseClasses)}>
+ <div className="flex items-center gap-x-3">
+ <span>{feature.text}</span>
+ </div>
+ {feature.tooltip && (
+ <TooltipProvider>
+ <Tooltip delayDuration={0}>
+ <TooltipTrigger asChild>
+ <div className="cursor-help">
+ <Users2Icon className="h-4 w-4 text-gray-500" />
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>{feature.tooltip}</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+ </div>
+ );
+ }
-// Add the PLAN_PRICING constant
-const PLAN_PRICING = {
- Pro: {
- extraUserPrice: {
- monthly: "€19/month per additional user",
- yearly: "€14/month per additional user",
- },
- },
- Business: {
- extraUserPrice: {
- monthly: "€26/month per additional user",
- yearly: "€19/month per additional user",
- },
- },
- "Data Rooms": {
- extraUserPrice: {
- monthly: "€49/month per additional user",
- yearly: "€33/month per additional user",
- },
- },
- "Data Rooms Plus": {
- extraUserPrice: {
- monthly: "€79/month per additional user",
- yearly: "€49/month per additional user",
- },
- },
+ return (
+ <div className={cn("text-sm", baseClasses)}>
+ <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-[#fb7a00]" />
+ <span>{feature.text}</span>
+ </div>
+ );
+};
+
+// Segmented control component for Base/Plus selection
+const PlanSelector = ({
+ value,
+ onChange,
+}: {
+ value: boolean;
+ onChange: (value: boolean) => void;
+}) => {
+ return (
+ <div className="mt-1 flex w-1/2 rounded-lg border border-gray-200 p-1">
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ !value
+ ? "bg-gray-300 text-foreground"
+ : "text-gray-600 hover:text-gray-900",
+ )}
+ onClick={() => onChange(false)}
+ >
+ Base
+ </button>
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ value
+ ? "bg-gray-900 text-white"
+ : "text-gray-600 hover:text-gray-900",
+ )}
+ onClick={() => onChange(true)}
+ >
+ Plus
+ </button>
+ </div>
+ );
};
-export enum PlanEnum {
- Pro = "Pro",
- Business = "Business",
- DataRooms = "Data Rooms",
- DataRoomsPlus = "Data Rooms Plus",
-}
export function UpgradePlanModal({
clickedPlan,
trigger,
@@ -76,244 +110,45 @@ export function UpgradePlanModal({
children?: React.ReactNode;
}) {
const router = useRouter();
-
const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");
- const [selectedPlan, setSelectedPlan] = useState<string | null>(null); // Track the clicked plan
+ const [selectedPlan, setSelectedPlan] = useState<string | null>(null);
const teamInfo = useTeam();
- const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();
+ const teamId = teamInfo?.currentTeam?.id;
+ const { plan: teamPlan, isCustomer, isOldAccount } = usePlan();
const analytics = useAnalytics();
const [showDataRoomsPlus, setShowDataRoomsPlus] = useState(false);
- const planFeatures = useMemo(
- () => ({
- Pro: {
- featureIntro: "Everything in Free, plus:",
- features: [
- "1 user included",
- "300 documents",
- "Unlimited links",
- <div key="custom-domain" className="flex items-center gap-x-3">
- <span>
- Custom domain <b>for documents</b>
- </span>
- </div>,
- "Folder organization",
- "Large file uploads",
- "Video sharing and analytics",
- // "Require email verification",
- "More file types: ppt, docx, excel",
- "Remove Papermark branding",
- "1-year analytics retention",
- ],
- },
- Business: {
- featureIntro: "Everything in Pro, plus:",
- features: [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <span>3 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>{PLAN_PRICING.Business.extraUserPrice[period]}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- "Unlimited data rooms",
- "1000 documents",
- <div key="custom-domain" className="flex items-center gap-x-3">
- <span>
- Custom domain <b>for documents</b>
- </span>
- </div>,
- "Unlimited folder levels",
- "Multi-file sharing",
- "Screen shield/fence protection",
- "Require email verification",
- "Allow/Block list",
- "Dataroom branding",
- "Webhooks",
- "More file types: dwg, kml, zip",
- "2-year analytics retention",
- ],
- },
- "Data Rooms": {
- featureIntro: "Everything in Business, plus:",
- features: showDataRoomsPlus
- ? [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <span>5 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {PLAN_PRICING["Data Rooms Plus"].extraUserPrice[period]}
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- <div key="storage" className="flex items-center gap-x-3">
- <span>
- <b>Unlimited</b> encrypted storage
- </span>
- </div>,
- "No file size limit",
- <div key="custom-domain" className="flex items-center gap-x-3">
- <span>
- Unlimited custom domains <b>for data rooms</b>
- </span>
- </div>,
- "Q&A module with custom permissions",
- "Automatic file indexing",
- "Assign users to particular data room",
- "Email invite viewers directly from Papermark",
- "White-labeling",
- "Dedicated account manager",
- "3-year analytics retention",
- ]
- : [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <span>3 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>{PLAN_PRICING["Data Rooms"].extraUserPrice[period]}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- "Unlimited data rooms",
- "Unlimited documents",
- <div key="custom-domain" className="flex items-center gap-x-3">
- <span>
- Custom domain <b>for data rooms</b>
- </span>
- </div>,
- "Data rooms analytics",
- "NDA agreements",
- "Dynamic watermark",
- "Granular user/group permissions",
- "Audit log for viewers",
- "24h priority support",
- "Custom onboarding",
- "2-year analytics retention",
- ],
- },
- "Data Rooms Plus": {
- featureIntro: "Everything in Data Rooms, plus:",
- features: [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <span>5 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {PLAN_PRICING["Data Rooms Plus"].extraUserPrice[period]}
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- <div key="storage" className="flex items-center gap-x-3">
- <span>
- <b>Unlimited</b> encrypted storage
- </span>
- </div>,
- "No file size limit",
- <div key="custom-domain" className="flex items-center gap-x-3">
- <span>
- Unlimited custom domains <b>for data rooms</b>
- </span>
- </div>,
- "Q&A module with custom permissions",
- "Automatic file indexing",
- "Assign users to particular data room",
- "Email invite viewers directly from Papermark",
- "White-labeling",
- "Dedicated account manager",
- "3-year analytics retention",
- ],
- },
- }),
- [period, showDataRoomsPlus],
- );
-
const plansToShow = useMemo(() => {
switch (clickedPlan) {
- case "Pro":
- return ["Pro", "Business"];
- case "Business":
- return ["Business", "Data Rooms"];
- case "Data Rooms":
- return ["Data Rooms", "Data Rooms Plus"];
- case "Data Rooms Plus":
- return ["Data Rooms", "Data Rooms Plus"];
+ case PlanEnum.Pro:
+ return [PlanEnum.Pro, PlanEnum.Business];
+ case PlanEnum.Business:
+ return [PlanEnum.Business, PlanEnum.DataRooms];
+ case PlanEnum.DataRooms:
+ return [PlanEnum.DataRooms, PlanEnum.DataRoomsPlus];
+ case PlanEnum.DataRoomsPlus:
+ return [PlanEnum.DataRooms, PlanEnum.DataRoomsPlus];
default:
- return ["Pro", "Business"];
+ return [PlanEnum.Pro, PlanEnum.Business];
}
}, [clickedPlan]);
- // Update this to check for Data Rooms plans
- const isDataRoomsPlans = useMemo(
- () => plansToShow.every((plan) => plan.includes("Data Rooms")),
- [plansToShow],
- );
-
// Track analytics event when modal is opened
useEffect(() => {
if (open) {
analytics.capture("Upgrade Button Clicked", {
trigger: trigger,
- teamId: teamInfo?.currentTeam?.id,
+ teamId,
});
+ } else {
+ setShowDataRoomsPlus(false);
}
}, [open, trigger]);
const handleUpgradeClick = () => {
analytics.capture("Upgrade Button Clicked", {
trigger: trigger,
- teamId: teamInfo?.currentTeam?.id,
+ teamId,
});
};
@@ -324,19 +159,11 @@ export function UpgradePlanModal({
? React.cloneElement(children, { onClick: handleUpgradeClick })
: children;
- // Add this helper function to get the correct plan name for button and pricing
- const getEffectivePlanName = (planOption: string) => {
- if (planOption === "Data Rooms" && showDataRoomsPlus) {
- return "Data Rooms Plus";
- }
- return planOption;
- };
-
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>{buttonChild}</DialogTrigger>
<DialogContent
- className="max-h-[90vh] overflow-y-auto bg-gray-50 text-foreground dark:bg-gray-900"
+ className="max-h-[90vh] min-h-fit overflow-y-auto bg-gray-50 text-foreground dark:bg-gray-900"
style={{
width: "90vw",
maxWidth: "900px",
@@ -356,164 +183,161 @@ export function UpgradePlanModal({
</div>
<div className="isolate grid grid-cols-1 gap-4 overflow-hidden rounded-xl p-4 md:grid-cols-2">
- {plansToShow.map((planOption) => (
- <div
- key={planOption}
- className={`relative flex flex-col rounded-lg border ${
- planOption === "Business" && plansToShow.includes("Data Rooms")
- ? "border-[#fb7a00]"
- : planOption === "Data Rooms Plus" &&
- plansToShow.includes("Data Rooms")
- ? "border-gray-900"
- : "border-gray-200"
- } bg-white p-6 shadow-sm dark:bg-gray-900`}
- >
- <div className="mb-4 border-b border-gray-200 pb-2">
- <div className="flex items-center justify-between">
- <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
- Papermark{" "}
- {showDataRoomsPlus &&
- planOption === "Data Rooms" &&
- plansToShow.includes("Business")
- ? "Data Rooms Plus"
- : planOption}
- </h3>
- {planOption === "Data Rooms" &&
- plansToShow.includes("Business") && (
- <button
- onClick={() => setShowDataRoomsPlus(!showDataRoomsPlus)}
- className="focus:outline-none"
- >
- {showDataRoomsPlus ? (
- <MinusCircleIcon className="h-6 w-6 text-[#fb7a00] hover:text-[#fb7a00]/90" />
- ) : (
- <PlusCircleIcon className="h-6 w-6 text-[#fb7a00] hover:text-[#fb7a00]/90" />
- )}
- </button>
- )}
- </div>
- {((planOption === "Business" &&
- plansToShow.includes("Data Rooms")) ||
- (planOption === "Data Rooms Plus" &&
- plansToShow.includes("Data Rooms"))) && (
+ {plansToShow.map((planOption) => {
+ const planFeatures = getPlanFeatures(planOption, {
+ period,
+ showDataRoomsPlus:
+ planOption === PlanEnum.DataRooms && showDataRoomsPlus,
+ });
+
+ // Get the effective plan name for display
+ const displayPlanName =
+ planOption === PlanEnum.DataRooms && showDataRoomsPlus
+ ? PlanEnum.DataRoomsPlus
+ : planOption;
+
+ const isDataRoomsUpgrade = plansToShow.includes(PlanEnum.DataRooms);
+
+ return (
+ <div
+ key={displayPlanName}
+ className={`relative flex flex-col rounded-lg border ${
+ planOption === PlanEnum.Business
+ ? "border-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPlus &&
+ isDataRoomsUpgrade
+ ? "border-gray-900"
+ : "border-gray-200"
+ } bg-white p-6 shadow-sm dark:bg-gray-900`}
+ >
+ <div className="mb-4 border-b border-gray-200 pb-2">
+ <div className="flex items-center justify-between">
+ <h3 className="text-balance text-xl font-medium text-gray-900 dark:text-white">
+ Papermark {displayPlanName}
+ </h3>
+ </div>
<span
- className={`absolute right-2 top-2 rounded px-2 py-1 text-xs text-white ${
- planOption === "Data Rooms Plus"
- ? "bg-gray-900"
- : "bg-[#fb7a00]"
- }`}
+ className={cn(
+ "absolute right-2 top-2 rounded px-2 py-1 text-xs text-white",
+ planOption === PlanEnum.Business && "bg-[#fb7a00]",
+ displayPlanName === PlanEnum.DataRoomsPlus &&
+ "bg-gray-900",
+ )}
>
- {planOption === "Data Rooms Plus"
- ? "Best deal"
- : "Most popular"}
+ {planOption === PlanEnum.Business && "Most popular"}
+ {displayPlanName === PlanEnum.DataRoomsPlus && "Best deal"}
</span>
- )}
- </div>
+ </div>
- {/* Update pricing section */}
- <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 === getEffectivePlanName(planOption),
- )?.price[period].amount
- }
- </span>
- <span className="text-gray-500 dark:text-white/75">/month</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
+ }
+ </span>
+ <span className="text-gray-500 dark:text-white/75">
+ /month
+ </span>
+ </div>
+
+ {planOption === PlanEnum.DataRooms &&
+ isDataRoomsUpgrade &&
+ !plansToShow.includes(PlanEnum.DataRoomsPlus) && (
+ <PlanSelector
+ value={showDataRoomsPlus}
+ onChange={setShowDataRoomsPlus}
+ />
+ )}
- <p className="mt-4 text-sm text-gray-600 dark:text-white">
- {
- planFeatures[planOption as keyof typeof planFeatures]
- .featureIntro
- }
- </p>
+ <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-muted-foreground">
- {planFeatures[
- planOption as keyof typeof planFeatures
- ].features.map((feature, i) => (
- <li key={i} className="flex items-center text-sm">
- <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-[#fb7a00]" />
- <span>{feature}</span>
- </li>
- ))}
- </ul>
+ <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-muted-foreground">
+ {planFeatures.features.map((feature, i) => (
+ <li key={i}>
+ <FeatureItem feature={feature} />
+ </li>
+ ))}
+ </ul>
- <div className="mt-auto">
- <Button
- variant={planOption === "Business" ? "default" : "outline"}
- className={`w-full py-2 text-sm ${
- planOption === "Business"
- ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
- : "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:hover:bg-gray-700/80"
- }`}
- loading={selectedPlan === planOption}
- disabled={selectedPlan !== null}
- onClick={() => {
- setSelectedPlan(planOption);
- if (isCustomer && teamPlan !== "free") {
- fetch(
- `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
- {
+ <div className="mt-auto">
+ <Button
+ variant={
+ planOption === PlanEnum.Business ? "default" : "outline"
+ }
+ className={`w-full py-2 text-sm ${
+ planOption === PlanEnum.Business
+ ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
+ : "bg-gray-800 text-white hover:bg-gray-900 hover:text-white dark:hover:bg-gray-700/80"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ setSelectedPlan(planOption);
+ if (isCustomer && teamPlan !== "free") {
+ fetch(`/api/teams/${teamId}/billing/manage`, {
method: "POST",
- },
- )
- .then(async (res) => {
- const url = await res.json();
- router.push(url);
})
- .catch((err) => {
- alert(err);
- setSelectedPlan(null);
- });
- } else {
- fetch(
- `/api/teams/${teamInfo?.currentTeam?.id}/billing/upgrade?priceId=${
- PLANS.find(
- (p) => p.name === getEffectivePlanName(planOption),
- )!.price[period].priceIds[
- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "production"
- : "test"
- ][isOldAccount ? "old" : "new"]
- }`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
+ .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=${
+ PLANS.find((p) => p.name === displayPlanName)!
+ .price[period].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV ===
+ "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"]
+ }`,
+ {
+ 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 ${getEffectivePlanName(planOption)} ${capitalize(period)}`}
- </Button>
+ )
+ .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>
- <div className="text-center">
+ <div className="flex flex-col items-center text-center text-sm text-muted-foreground">
+ All plans include unlimited viewers and page by page document
+ analytics.
<Link
href="/settings/upgrade"
- className="text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
+ className="underline underline-offset-4 hover:text-foreground"
>
- See all plans. All plans include unlimited viewers and page by page
- document analytics.
+ See all plans
</Link>
</div>
</DialogContent>
diff --git a/components/datarooms/add-dataroom-modal.tsx b/components/datarooms/add-dataroom-modal.tsx
index 9a223021..0df4aa69 100644
--- a/components/datarooms/add-dataroom-modal.tsx
+++ b/components/datarooms/add-dataroom-modal.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { toast } from "sonner";
import { mutate } from "swr";
import { z } from "zod";
@@ -23,7 +24,7 @@ import { Label } from "@/components/ui/label";
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
export function AddDataroomModal({
children,
diff --git a/components/datarooms/dataroom-trial-modal.tsx b/components/datarooms/dataroom-trial-modal.tsx
index c5bcf020..40f5455b 100644
--- a/components/datarooms/dataroom-trial-modal.tsx
+++ b/components/datarooms/dataroom-trial-modal.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { E164Number } from "libphonenumber-js";
import { toast } from "sonner";
import { mutate } from "swr";
@@ -22,7 +23,7 @@ import { Label } from "@/components/ui/label";
import { useAnalytics } from "@/lib/analytics";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import { PhoneInput } from "../ui/phone-input";
import {
Select,
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsx
index a96b837f..06bb8564 100644
--- a/components/documents/add-document-modal.tsx
+++ b/components/documents/add-document-modal.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { FormEvent, useEffect, useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { usePlausible } from "next-plausible";
import { parsePageId } from "notion-utils";
import { toast } from "sonner";
@@ -39,7 +40,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
import { getSupportedContentType } from "@/lib/utils/get-content-type";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
export function AddDocumentModal({
newVersion,
@@ -470,15 +471,20 @@ export function AddDocumentModal({
return;
}
- toast.success("Figma presentation processed. Redirecting to document page...");
+ toast.success(
+ "Figma presentation processed. Redirecting to document page...",
+ );
router.push("/documents/" + document.id);
}
} catch (error) {
setUploading(false);
toast.error(
- "Oops! Can't access the Figma presentation. Please check if it's publicly accessible."
+ "Oops! Can't access the Figma presentation. Please check if it's publicly accessible.",
+ );
+ console.error(
+ "An error occurred while processing the Figma link: ",
+ error,
);
- console.error("An error occurred while processing the Figma link: ", error);
} finally {
setUploading(false);
setIsOpen(false);
@@ -667,7 +673,8 @@ export function AddDocumentModal({
<CardHeader className="space-y-3">
<CardTitle>Share a Figma Presentation</CardTitle>
<CardDescription>
- Share your Figma presentation deck. Make sure your presentation is publicly accessible.
+ Share your Figma presentation deck. Make sure your
+ presentation is publicly accessible.
</CardDescription>
</CardHeader>
<CardContent className="space-y-2">
diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsx
index 7590f8aa..406c3c3e 100644
--- a/components/documents/document-card.tsx
+++ b/components/documents/document-card.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
import { TeamContextType } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import {
BetweenHorizontalStartIcon,
FolderInputIcon,
@@ -33,7 +34,7 @@ import { cn, nFormatter, timeAgo } from "@/lib/utils";
import { fileIcon } from "@/lib/utils/get-file-icon";
import { useCopyToClipboard } from "@/lib/utils/use-copy-to-clipboard";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import { DataroomTrialModal } from "../datarooms/dataroom-trial-modal";
import { AddToDataroomModal } from "./add-document-to-dataroom-modal";
import { MoveToFolderModal } from "./move-folder-modal";
diff --git a/components/documents/document-header.tsx b/components/documents/document-header.tsx
index 574a081d..d19d9143 100644
--- a/components/documents/document-header.tsx
+++ b/components/documents/document-header.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useEffect, useRef, useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { Document, DocumentVersion } from "@prisma/client";
import {
AlertCircleIcon,
@@ -44,7 +45,7 @@ import { cn } from "@/lib/utils";
import { fileIcon } from "@/lib/utils/get-file-icon";
import PlanBadge from "../billing/plan-badge";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import AdvancedSheet from "../shared/icons/advanced-sheet";
import PortraitLandscape from "../shared/icons/portrait-landscape";
import { Alert, AlertClose, AlertDescription, AlertTitle } from "../ui/alert";
diff --git a/components/domains/add-domain-modal.tsx b/components/domains/add-domain-modal.tsx
index 16dcdec7..3456f4d5 100644
--- a/components/domains/add-domain-modal.tsx
+++ b/components/domains/add-domain-modal.tsx
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { toast } from "sonner";
import { z } from "zod";
@@ -21,7 +22,7 @@ import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
export function AddDomainModal({
open,
diff --git a/components/folders/add-folder-modal.tsx b/components/folders/add-folder-modal.tsx
index 8adc0415..27c910dc 100644
--- a/components/folders/add-folder-modal.tsx
+++ b/components/folders/add-folder-modal.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { Folder } from "@prisma/client";
import { toast } from "sonner";
import { mutate } from "swr";
@@ -24,7 +25,7 @@ import { Label } from "@/components/ui/label";
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
export function AddFolderModal({
// open,
diff --git a/components/links/link-sheet/link-options.tsx b/components/links/link-sheet/link-options.tsx
index 3e8e9a77..73fb5394 100644
--- a/components/links/link-sheet/link-options.tsx
+++ b/components/links/link-sheet/link-options.tsx
@@ -1,11 +1,9 @@
import { useState } from "react";
+import { PlanEnum } from "@/ee/stripe/constants";
import { LinkAudienceType, LinkType } from "@prisma/client";
-import {
- PlanEnum,
- UpgradePlanModal,
-} from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
import { DEFAULT_LINK_TYPE } from "@/components/links/link-sheet";
import AllowDownloadSection from "@/components/links/link-sheet/allow-download-section";
import AllowListSection from "@/components/links/link-sheet/allow-list-section";
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsx
index 67c7f210..bd4932dc 100644
--- a/components/sidebar/app-sidebar.tsx
+++ b/components/sidebar/app-sidebar.tsx
@@ -7,6 +7,7 @@ import * as React from "react";
import { useEffect, useState } from "react";
import { TeamContextType, initialState, useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import Cookies from "js-cookie";
import {
BrushIcon,
@@ -37,7 +38,6 @@ import { nFormatter } from "@/lib/utils";
import ProAnnualBanner from "../billing/pro-annual-banner";
import ProBanner from "../billing/pro-banner";
-import { PlanEnum } from "../billing/upgrade-plan-modal";
import { Progress } from "../ui/progress";
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
diff --git a/components/sidebar/nav-main.tsx b/components/sidebar/nav-main.tsx
index 6b85e624..8fc5bd7c 100644
--- a/components/sidebar/nav-main.tsx
+++ b/components/sidebar/nav-main.tsx
@@ -2,6 +2,7 @@
import Link from "next/link";
+import { PlanEnum } from "@/ee/stripe/constants";
import { ChevronRight, type LucideIcon } from "lucide-react";
import {
@@ -23,7 +24,7 @@ import {
import { cn } from "@/lib/utils";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
export interface NavItem {
title: string;
diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsx
index 1a1b4b55..1d90abfd 100644
--- a/components/visitors/visitors-table.tsx
+++ b/components/visitors/visitors-table.tsx
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { DocumentVersion } from "@prisma/client";
import {
AlertTriangleIcon,
@@ -41,7 +42,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useDocumentVisits } from "@/lib/swr/use-document";
import { durationFormat, timeAgo } from "@/lib/utils";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import { Button } from "../ui/button";
import {
DropdownMenu,
diff --git a/components/welcome/dataroom-trial.tsx b/components/welcome/dataroom-trial.tsx
index 3bd8a8bb..c8061bd4 100644
--- a/components/welcome/dataroom-trial.tsx
+++ b/components/welcome/dataroom-trial.tsx
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { useState } from "react";
import { useTeam } from "@/context/team-context";
+import { PlanEnum } from "@/ee/stripe/constants";
import { E164Number } from "libphonenumber-js";
import { motion } from "motion/react";
import { toast } from "sonner";
@@ -22,7 +23,7 @@ import {
import { useAnalytics } from "@/lib/analytics";
import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";
-import { PlanEnum, UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import { Input } from "../ui/input";
export default function DataroomTrial() {
diff --git a/ee/stripe/constants.ts b/ee/stripe/constants.ts
new file mode 100644
index 00000000..51a2e548
--- /dev/null
+++ b/ee/stripe/constants.ts
@@ -0,0 +1,231 @@
+export enum PlanEnum {
+ Pro = "Pro",
+ Business = "Business",
+ DataRooms = "Data Rooms",
+ DataRoomsPlus = "Data Rooms Plus",
+}
+
+export type PeriodType = "monthly" | "yearly";
+
+export interface Feature {
+ id: string;
+ text: string;
+ highlight?: boolean;
+ tooltip?: string;
+ isCustomDomain?: boolean;
+ isUsers?: boolean;
+ usersIncluded?: number;
+ isHighlighted?: boolean;
+}
+
+export interface PlanFeatures {
+ featureIntro: string;
+ features: Feature[];
+}
+
+export const PLAN_PRICING = {
+ Pro: {
+ extraUserPrice: {
+ monthly: "€19/month per additional user",
+ yearly: "€14/month per additional user",
+ },
+ },
+ Business: {
+ extraUserPrice: {
+ monthly: "€26/month per additional user",
+ yearly: "€19/month per additional user",
+ },
+ },
+ "Data Rooms": {
+ extraUserPrice: {
+ monthly: "€49/month per additional user",
+ yearly: "€33/month per additional user",
+ },
+ },
+ "Data Rooms Plus": {
+ extraUserPrice: {
+ monthly: "€79/month per additional user",
+ yearly: "€49/month per additional user",
+ },
+ },
+} as const;
+
+export const BASE_FEATURES: Record<PlanEnum, PlanFeatures> = {
+ [PlanEnum.Pro]: {
+ featureIntro: "Everything in Free, plus:",
+ features: [
+ { id: "users", text: "1 user included", isUsers: true, usersIncluded: 1 },
+ { id: "documents", text: "300 documents" },
+ { id: "links", text: "Unlimited links" },
+ {
+ id: "custom-domain",
+ text: "Custom domain for documents",
+ isCustomDomain: true,
+ },
+ { id: "folder", text: "Folder organization" },
+ { id: "uploads", text: "Large file uploads" },
+ { id: "video", text: "Video sharing and analytics" },
+ { id: "file-types-basic", text: "More file types: ppt, docx, excel" },
+ { id: "branding", text: "Remove Papermark branding" },
+ { id: "retention", text: "1-year analytics retention" },
+ ],
+ },
+ [PlanEnum.Business]: {
+ featureIntro: "Everything in Pro, plus:",
+ features: [
+ {
+ id: "users",
+ text: "3 users included",
+ isUsers: true,
+ usersIncluded: 3,
+ },
+ { id: "datarooms", text: "Unlimited data rooms" },
+ { id: "documents", text: "1000 documents" },
+ {
+ id: "custom-domain",
+ text: "Custom domain for documents",
+ isCustomDomain: true,
+ },
+ { id: "folder-levels", text: "Unlimited folder levels" },
+ { id: "multi-file", text: "Multi-file sharing" },
+ { id: "screen-shield", text: "Screen shield/fence protection" },
+ { id: "email-verify", text: "Require email verification" },
+ { id: "allow-block", text: "Allow/Block list" },
+ { id: "dataroom-branding", text: "Dataroom branding" },
+ { id: "webhooks", text: "Webhooks" },
+ { id: "file-types-advanced", text: "More file types: dwg, kml, zip" },
+ { id: "retention", text: "2-year analytics retention" },
+ ],
+ },
+ [PlanEnum.DataRooms]: {
+ featureIntro: "Everything in Business, plus:",
+ features: [
+ {
+ id: "users",
+ text: "3 users included",
+ isUsers: true,
+ usersIncluded: 3,
+ },
+ { id: "datarooms", text: "Unlimited data rooms" },
+ { id: "documents", text: "Unlimited documents" },
+ {
+ id: "custom-domain",
+ text: "Custom domain for data rooms",
+ isCustomDomain: true,
+ },
+ { id: "analytics", text: "Data rooms analytics" },
+ { id: "nda", text: "NDA agreements" },
+ { id: "watermark", text: "Dynamic watermark" },
+ { id: "permissions", text: "Granular user/group permissions" },
+ { id: "audit", text: "Audit log for viewers" },
+ { id: "support", text: "24h priority support" },
+ { id: "onboarding", text: "Custom onboarding" },
+ { id: "retention", text: "2-year analytics retention" },
+ ],
+ },
+ [PlanEnum.DataRoomsPlus]: {
+ featureIntro: "Everything in Data Rooms, plus:",
+ features: [
+ {
+ id: "users",
+ text: "5 users included",
+ isUsers: true,
+ usersIncluded: 5,
+ },
+ { id: "storage", text: "Unlimited encrypted storage", highlight: true },
+ { id: "file-size", text: "No file size limit" },
+ {
+ id: "custom-domain",
+ text: "Unlimited custom domains for data rooms",
+ isCustomDomain: true,
+ highlight: true,
+ },
+ { id: "qa", text: "Q&A module with custom permissions" },
+ { id: "indexing", text: "Automatic file indexing" },
+ { id: "assign", text: "Assign users to particular data room" },
+ { id: "invite", text: "Email invite viewers directly from Papermark" },
+ { id: "white-label", text: "White-labeling" },
+ { id: "account-manager", text: "Dedicated account manager" },
+ { id: "retention", text: "3-year analytics retention" },
+ ],
+ },
+};
+
+interface FeatureOptions {
+ period?: PeriodType;
+ showHighlighted?: boolean;
+ maxFeatures?: number;
+ excludeFeatures?: string[];
+ includeFeatures?: string[];
+ highlightFeatures?: string[];
+ showDataRoomsPlus?: boolean;
+}
+
+export function getPlanFeatures(
+ plan: PlanEnum,
+ options: FeatureOptions = {},
+): PlanFeatures {
+ const {
+ period = "monthly",
+ showHighlighted = false,
+ maxFeatures,
+ excludeFeatures = [],
+ includeFeatures = [],
+ highlightFeatures = [],
+ showDataRoomsPlus = false,
+ } = options;
+
+ // If showing Data Rooms Plus features instead of Data Rooms
+ let effectivePlan = plan;
+ if (showDataRoomsPlus && plan === PlanEnum.DataRooms) {
+ effectivePlan = PlanEnum.DataRoomsPlus;
+ }
+
+ const basePlanFeatures = BASE_FEATURES[effectivePlan];
+ let features = [...basePlanFeatures.features];
+
+ // Filter features based on options
+ if (includeFeatures.length > 0) {
+ features = features.filter((feature) =>
+ includeFeatures.includes(feature.id),
+ );
+ }
+
+ if (excludeFeatures.length > 0) {
+ features = features.filter(
+ (feature) => !excludeFeatures.includes(feature.id),
+ );
+ }
+
+ // Add pricing tooltip for user features and handle highlighting
+ features = features.map((feature) => {
+ const newFeature = { ...feature };
+
+ if (feature.isUsers) {
+ // Use the pricing from the effective plan
+ newFeature.tooltip = PLAN_PRICING[effectivePlan].extraUserPrice[period];
+ }
+
+ // Add isHighlighted property if feature is in highlightFeatures
+ if (highlightFeatures.includes(feature.id)) {
+ newFeature.isHighlighted = true;
+ }
+
+ return newFeature;
+ });
+
+ // Only show highlighted features if specified
+ if (showHighlighted) {
+ features = features.filter((feature) => feature.highlight);
+ }
+
+ // Limit number of features if specified
+ if (maxFeatures) {
+ features = features.slice(0, maxFeatures);
+ }
+
+ return {
+ featureIntro: basePlanFeatures.featureIntro,
+ features,
+ };
+}
diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx
index be64eaca..5259d801 100644
--- a/pages/settings/billing.tsx
+++ b/pages/settings/billing.tsx
@@ -1,6 +1,6 @@
import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
+import { useEffect } from "react";
import { useTeam } from "@/context/team-context";
import { toast } from "sonner";
@@ -12,287 +12,32 @@ import { SettingsHeader } from "@/components/settings/settings-header";
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
-const frequencies: {
- value: "monthly" | "annually";
- label: "Monthly" | "Annually";
- priceSuffix: "/month" | "/month";
-}[] = [
- { value: "monthly", label: "Monthly", priceSuffix: "/month" },
- { value: "annually", label: "Annually", priceSuffix: "/month" },
-];
-
export default function Billing() {
const router = useRouter();
const analytics = useAnalytics();
- const { plan, isCustomer } = usePlan();
- const [clicked, setClicked] = useState<boolean>(false);
- const frequency = frequencies[1];
- const [toggleProYear, setToggleProYear] = useState<boolean>(true);
- const [toggleBusinessYear, setToggleBusinessYear] = useState<boolean>(true);
- const [toggleDataroomsYear, setToggleDataroomsYear] = useState<boolean>(true);
- const [frequencyPro, setFrequencyPro] = useState(frequencies[0]);
- const [frequencyBusiness, setFrequencyBusiness] = useState(frequencies[0]);
- const [frequencyDatarooms, setFrequencyDatarooms] = useState(frequencies[0]);
- const [showDataRoomsPlus, setShowDataRoomsPlus] = useState(false);
-
- useEffect(() => {
- if (toggleProYear) {
- setFrequencyPro(frequencies[1]);
- } else {
- setFrequencyPro(frequencies[0]);
- }
-
- if (toggleBusinessYear) {
- setFrequencyBusiness(frequencies[1]);
- } else {
- setFrequencyBusiness(frequencies[0]);
- }
- if (toggleDataroomsYear) {
- setFrequencyDatarooms(frequencies[1]);
- } else {
- setFrequencyDatarooms(frequencies[0]);
- }
- }, [toggleProYear, toggleBusinessYear, toggleDataroomsYear]);
const teamInfo = useTeam();
+ const teamId = teamInfo?.currentTeam?.id;
+
+ const { plan } = usePlan();
useEffect(() => {
if (router.query.success) {
toast.success("Upgrade success!");
analytics.capture("User Upgraded", {
plan: plan,
- teamId: teamInfo?.currentTeam?.id,
- $set: { teamId: teamInfo?.currentTeam?.id, teamPlan: plan },
+ teamId: teamId,
+ $set: { teamId: teamId, teamPlan: plan },
});
}
if (router.query.cancel) {
analytics.capture("Stripe Checkout Cancelled", {
- teamId: teamInfo?.currentTeam?.id,
+ teamId: teamId,
});
}
}, [router.query]);
- const tiers: {
- name: string;
- id: string;
- href: string;
- currentPlan: boolean;
- price: {
- monthly: string;
- annually: string;
- };
- description: string;
- featureIntro: string;
- features: string[];
- bgColor: string;
- borderColor: string;
- textColor: string;
- buttonText: string;
- mostPopular: boolean;
- }[] = [
- {
- name: "Free",
- id: "tier-free",
- href: "/login",
- currentPlan: plan && plan == "free" ? true : false,
- price: { monthly: "€0", annually: "€0" },
- description: "The essentials to start sharing documents securely.",
- featureIntro: "What's included:",
- features: [
- "1 user",
- "50 links",
- "50 documents",
- "Unlimited visitors",
- "Page-by-page analytics",
- "Document sharing controls",
- "Password protection",
- "30-day analytics retention",
- ],
- bgColor: "bg-gray-200",
- borderColor: "#bg-gray-800",
- textColor: "text-foreground ",
- buttonText: "Start for free",
- mostPopular: false,
- },
- {
- name: "Pro",
- id: "tier-pro",
- href: "/login",
- currentPlan: plan && plan == "pro" ? true : false,
- price: { monthly: "€29", annually: "€24" },
- description: "The branded experience for your documents.",
- featureIntro: "Everything in Free, plus:",
- features: [
- "1 user included",
- "Unlimited links",
- "300 documents",
- "Custom branding",
- "Folder organization",
- "Large file uploads",
- // "Require email verification",
- "More file types: ppt, docx, excel",
- "Video sharing and analytics",
- "Remove Papermark branding",
- "1-year analytics retention",
- ],
- bgColor: "bg-gray-200",
- borderColor: "#bg-gray-800",
- textColor: "#bg-gray-500",
- buttonText: "Upgrade to Pro",
- mostPopular: false,
- },
- {
- name: "Business",
- id: "tier-business",
- href: "/login",
- currentPlan: plan && plan == "business" ? true : false,
- price: { monthly: "€79", annually: "€59" },
- description:
- "The one for more control, data room, and multi-file sharing.",
- featureIntro: "Everything in Pro, plus:",
- features: [
- "3 users included",
- "Unlimited data rooms",
- "1000 documents",
- "Custom domain for documents",
- "Unlimited folder levels",
- "Multi-file sharing",
- "Screen shield/fence protection",
- "Allow/Block list",
- "Dataroom branding",
- "Webhooks",
- "More file types: dwg, kml, zip",
- "2-year analytics retention",
- ],
- bgColor: "#bg-gray-500",
- borderColor: "#fb7a00",
- textColor: "#bg-gray-500",
- buttonText: "Upgrade to Business",
- mostPopular: true,
- },
- {
- name: "Data Rooms",
- id: "tier-datarooms",
- href: "/login",
- currentPlan: plan && plan == "datarooms" ? true : false,
- price: { monthly: "€149", annually: "€99" },
- description:
- "The one for more control, data room, and multi-file sharing.",
- featureIntro: "Everything in Business, plus:",
- features: [
- "3 users included",
- "Unlimited data rooms",
- "Unlimited documents",
- "One custom domain for data rooms",
- "Data rooms analytics",
- "NDA agreements",
- "Dynamic watermark",
- "Granular user/group permissions",
- "Audit log for viewers",
- "24h priority support",
- "Custom onboarding",
- "2-year analytics retention",
- ],
- bgColor: "#fb7a00",
- borderColor: "#fb7a00",
- textColor: "#black",
- buttonText: "Upgrade to Data Rooms",
- mostPopular: true,
- },
- {
- name: "Data Rooms Plus",
- id: "tier-datarooms-plus",
- href: "/login",
- currentPlan: plan && plan == "datarooms-plus" ? true : false,
- price: { monthly: "€299", annually: "€199" },
- description:
- "The ultimate data room solution with advanced features and unlimited storage.",
- featureIntro: "Everything in Data Rooms, plus:",
- features: [
- "5 users included",
- "Unlimited storage",
- "No file size limit",
- "Unlimited custom domains for data rooms",
- "Q&A module with permissions",
- "Automatic file indexing",
- "Assign users to data room",
- "Email invite viewers directly from Papermark",
- "White-labeling",
- "Dedicated account manager",
- "3-year analytics retention",
- ],
- bgColor: "bg-gray-900",
- borderColor: "border-gray-900",
- textColor: "text-white",
- buttonText: "Upgrade to Data Rooms Plus",
- mostPopular: true,
- },
- ];
-
- const enterpriseFeatures = [
- "Self-hosted version",
- "Bring your own storage for documents",
- "Unlimited users",
- "Unlimited documents",
- "Unlimited folders and subfolders",
- "Unlimited datarooms",
- "Unlimited storage",
- "Full white-labeling",
- "No file size limit",
- "Single sign-on (SSO)",
- "Dedicated support",
- "Custom onboarding",
- ];
-
- const displayTiers = tiers.filter(
- (tier) =>
- tier.name !== (showDataRoomsPlus ? "Data Rooms" : "Data Rooms Plus"),
- );
-
- const dataRoomsIndex = displayTiers.findIndex(
- (tier) => tier.name === "Data Rooms" || tier.name === "Data Rooms Plus",
- );
-
- if (dataRoomsIndex !== -1) {
- const currentTier = displayTiers[dataRoomsIndex];
- displayTiers[dataRoomsIndex] = {
- ...currentTier,
- name: showDataRoomsPlus ? "Data Rooms Plus" : "Data Rooms",
- price: showDataRoomsPlus
- ? { monthly: "€299", annually: "€249" }
- : { monthly: "€199", annually: "€99" },
- features: showDataRoomsPlus
- ? [
- "5 users included",
- "Unlimited encrypted storage",
- "No file size limit",
- "Unlimited custom domains for data rooms",
- "Q&A module with custom permissions",
- "Automatic file indexing",
- "Assign users to particular data room",
- "Email invite viewers directly from Papermark",
- "White-labeling",
- "Dedicated account manager",
- "3-year analytics retention",
- ]
- : [
- "3 users included",
- "Unlimited data rooms",
- "Unlimited documents",
- "One custom domain for data rooms",
- "Data rooms analytics",
- "NDA agreements",
- "Dynamic watermark",
- "Granular user/group permissions",
- "Audit log for viewers",
- "24h priority support",
- "Custom onboarding",
- "2-year analytics retention",
- ],
- };
- }
-
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">
diff --git a/pages/settings/upgrade.tsx b/pages/settings/upgrade.tsx
index 0f2f1863..65fbae55 100644
--- a/pages/settings/upgrade.tsx
+++ b/pages/settings/upgrade.tsx
@@ -5,6 +5,7 @@ import React from "react";
import { useTeam } from "@/context/team-context";
import { getStripe } from "@/ee/stripe/client";
+import { Feature, PlanEnum, getPlanFeatures } from "@/ee/stripe/constants";
import { PLANS } from "@/ee/stripe/utils";
import { CheckIcon, Users2Icon } from "lucide-react";
@@ -21,32 +22,56 @@ import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
import { capitalize } from "@/lib/utils";
-// First define the pricing data structure outside the component
-const PLAN_PRICING = {
- Pro: {
- extraUserPrice: {
- monthly: "€19/month per additional user",
- yearly: "€14/month per additional user",
- },
- },
- Business: {
- extraUserPrice: {
- monthly: "€26/month per additional user",
- yearly: "€19/month per additional user",
- },
- },
- "Data Rooms": {
- extraUserPrice: {
- monthly: "€49/month per additional user",
- yearly: "€33/month per additional user",
- },
- },
- "Data Rooms Plus": {
- extraUserPrice: {
- monthly: "€79/month per additional user",
- yearly: "€49/month per additional user",
- },
- },
+// Feature rendering component
+const FeatureItem = ({
+ feature,
+ period,
+}: {
+ feature: Feature;
+ period: "monthly" | "yearly";
+}) => {
+ const baseClasses = `flex items-center ${feature.isHighlighted ? "bg-orange-50 -mx-6 px-6 py-2 rounded-md dark:bg-orange-900/20" : ""}`;
+
+ if (feature.isUsers) {
+ return (
+ <div className={`justify-between gap-x-8 ${baseClasses}`}>
+ <div className="flex items-center gap-x-3">
+ <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
+ <span>{feature.text}</span>
+ </div>
+ {feature.tooltip && (
+ <TooltipProvider>
+ <Tooltip delayDuration={0}>
+ <TooltipTrigger asChild>
+ <div className="cursor-help">
+ <Users2Icon className="h-4 w-4 text-gray-500" />
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>{feature.tooltip}</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+ </div>
+ );
+ }
+
+ if (feature.isCustomDomain) {
+ return (
+ <span className={`gap-x-3 ${baseClasses}`}>
+ <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
+ <span>{feature.text}</span>
+ </span>
+ );
+ }
+
+ return (
+ <div className={`gap-x-3 ${baseClasses}`}>
+ <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
+ <span>{feature.text}</span>
+ </div>
+ );
};
export default function UpgradePage() {
@@ -57,162 +82,12 @@ export default function UpgradePage() {
const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();
const analytics = useAnalytics();
- const planFeatures = useMemo(
- () => ({
- Pro: {
- featureIntro: "Everything in Free, plus:",
- features: [
- "1 user included",
- "Unlimited links",
- "300 documents",
- "Custom branding",
- "Folder organization",
- "Large file uploads",
- // "Require email verification",
- "More file types: ppt, docx, excel",
- "Video sharing and analytics",
- "Remove Papermark branding",
- "1-year analytics retention",
- ],
- },
- Business: {
- featureIntro: "Everything in Pro, plus:",
- features: [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>3 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>{PLAN_PRICING.Business.extraUserPrice[period]}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- "1 dataroom",
- "1000 documents",
- <span key="custom-domain" className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>
- Custom domain <b>for documents</b>
- </span>
- </span>,
- "Unlimited folder levels",
- "Multi-file sharing",
- "Screen shield/fence protection",
- "Allow/Block list",
- "Dataroom branding",
- "Webhooks",
- "More file types: dwg, kml, zip",
- "2-year analytics retention",
- ],
- },
- "Data Rooms": {
- featureIntro: "Everything in Business, plus:",
- features: [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>3 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>{PLAN_PRICING["Data Rooms"].extraUserPrice[period]}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
- "Unlimited data rooms",
- "Unlimited documents",
- <span key="custom-domain" className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>
- One custom domain <b>for data rooms</b>
- </span>
- </span>,
- "Data rooms analytics",
- "NDA agreements",
- "Dynamic watermark",
- "Granular user/group permissions",
- "Audit log for viewers",
- "24h priority support",
- "Custom onboarding",
- "2-year analytics retention",
- ],
- },
- "Data Rooms Plus": {
- featureIntro: "Everything in Data Rooms, plus:",
- features: [
- <div
- key="users"
- className="flex items-center justify-between gap-x-8"
- >
- <div className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>5 users included</span>
- </div>
- <TooltipProvider>
- <Tooltip delayDuration={0}>
- <TooltipTrigger asChild>
- <div className="cursor-help">
- <Users2Icon className="h-4 w-4 text-gray-500" />
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {PLAN_PRICING["Data Rooms Plus"].extraUserPrice[period]}
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>,
-
- <span key="custom-domain" className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>
- <b>Unlimited</b> encrypted storage
- </span>
- </span>,
- "No file size limit",
- <span key="custom-domain" className="flex items-center gap-x-3">
- <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
- <span>
- Unlimited custom domains <b>for data rooms</b>
- </span>
- </span>,
- "Q&A module with custom permissions",
- "Automatic file indexing",
- "Assign users to particular data room",
- "Email invite viewers directly from Papermark",
- "White-labeling",
- "Dedicated account manager",
- "3-year analytics retention",
- ],
- },
- }),
- [period],
- );
-
- const plansToShow = ["Pro", "Business", "Data Rooms", "Data Rooms Plus"];
+ const plansToShow = [
+ PlanEnum.Pro,
+ PlanEnum.Business,
+ PlanEnum.DataRooms,
+ PlanEnum.DataRoomsPlus,
+ ];
return (
<div className="min-h-screen bg-gray-50 p-8 dark:bg-gray-900">
@@ -234,137 +109,131 @@ export default function UpgradePage() {
</div>
<div className="grid grid-cols-1 gap-2 md:grid-cols-4">
- {plansToShow.map((planOption) => (
- <div
- key={planOption}
- className={`relative flex flex-col rounded-lg border ${
- planOption === "Business"
- ? "border-[#fb7a00]"
- : planOption === "Data Rooms Plus"
- ? "border-gray-900"
- : "border-gray-200"
- } bg-white p-6 shadow-sm dark:bg-gray-900`}
- >
- <div className="mb-4 border-b border-gray-200 pb-2">
- <h3 className="text-balance text-xl font-medium text-foreground text-gray-900 dark:text-white">
- Papermark {planOption}
- </h3>
- {(planOption === "Business" ||
- planOption === "Data Rooms Plus") && (
- <span
- className={`absolute -top-3 right-4 rounded px-2 py-1 text-xs text-white ${
- planOption === "Data Rooms Plus"
- ? "bg-gray-900"
- : "bg-[#fb7a00]"
- }`}
- >
- {planOption === "Data Rooms Plus"
- ? "Best offer"
- : "Most popular"}
- </span>
- )}
- </div>
-
- <div className="mb-2 text-balance text-4xl font-medium tabular-nums text-foreground">
- €{PLANS.find((p) => p.name === planOption)!.price[period].amount}
- <span className="text-base font-normal dark:text-white/75">
- /month
- </span>
- </div>
- <p className="mt-4 text-sm text-gray-600 dark:text-white">
- {
- planFeatures[planOption as keyof typeof planFeatures]
- .featureIntro
- }
- </p>
+ {plansToShow.map((planOption) => {
+ const planFeatures = getPlanFeatures(planOption, { period });
- <ul
- role="list"
- className="mb-4 mt-4 space-y-3 text-sm leading-6 text-gray-600"
+ return (
+ <div
+ key={planOption}
+ className={`relative flex flex-col rounded-lg border ${
+ planOption === PlanEnum.Business
+ ? "border-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPlus
+ ? "border-gray-900"
+ : "border-gray-200"
+ } bg-white p-6 shadow-sm dark:bg-gray-900`}
>
- {planFeatures[
- planOption as keyof typeof planFeatures
- ].features.map((feature, i) => (
- <li key={i} className="flex items-center text-sm">
- {typeof feature === "string" ? (
- <>
- <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-[#fb7a00]" />
- <span>{feature}</span>
- </>
- ) : React.isValidElement(feature) ? (
- feature
- ) : (
- feature
- )}
- </li>
- ))}
- </ul>
- <div className="mt-auto">
- <Button
- variant={planOption === "Business" ? "default" : "default"}
- className={`w-full py-2 text-sm ${
- planOption === "Business"
- ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
- : "bg-gray-800 text-white hover:bg-gray-900 dark:hover:bg-gray-700/80"
- }`}
- loading={selectedPlan === planOption}
- disabled={selectedPlan !== null}
- onClick={() => {
- setSelectedPlan(planOption);
- if (isCustomer && teamPlan !== "free") {
- fetch(
- `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
- {
- method: "POST",
- },
- )
- .then(async (res) => {
- const url = await res.json();
- router.push(url);
- })
- .catch((err) => {
- alert(err);
- setSelectedPlan(null);
- });
- } else {
- fetch(
- `/api/teams/${
- teamInfo?.currentTeam?.id
- }/billing/upgrade?priceId=${
- PLANS.find((p) => p.name === planOption)!.price[period]
- .priceIds[
- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "production"
- : "test"
- ][isOldAccount ? "old" : "new"]
- }`,
- {
- 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);
- });
- }
- }}
+ <div className="mb-4 border-b border-gray-200 pb-2">
+ <h3 className="text-balance text-xl font-medium text-foreground text-gray-900 dark:text-white">
+ Papermark {planOption}
+ </h3>
+ {(planOption === PlanEnum.Business ||
+ planOption === PlanEnum.DataRoomsPlus) && (
+ <span
+ className={`absolute -top-3 right-4 rounded px-2 py-1 text-xs text-white ${
+ planOption === PlanEnum.DataRoomsPlus
+ ? "bg-gray-900"
+ : "bg-[#fb7a00]"
+ }`}
+ >
+ {planOption === PlanEnum.DataRoomsPlus
+ ? "Best offer"
+ : "Most popular"}
+ </span>
+ )}
+ </div>
+
+ <div className="mb-2 text-balance text-4xl font-medium tabular-nums text-foreground">
+ €
+ {PLANS.find((p) => p.name === planOption)!.price[period].amount}
+ <span className="text-base font-normal dark:text-white/75">
+ /month
+ </span>
+ </div>
+ <p className="mt-4 text-sm text-gray-600 dark:text-white">
+ {planFeatures.featureIntro}
+ </p>
+
+ <ul
+ role="list"
+ className="mb-4 mt-4 space-y-3 text-sm leading-6 text-gray-600"
>
- {selectedPlan === planOption
- ? "Redirecting to Stripe..."
- : `Upgrade to ${planOption} ${capitalize(period)}`}
- </Button>
+ {planFeatures.features.map((feature, i) => (
+ <li key={i}>
+ <FeatureItem feature={feature} period={period} />
+ </li>
+ ))}
+ </ul>
+ <div className="mt-auto">
+ <Button
+ variant={
+ planOption === PlanEnum.Business ? "default" : "default"
+ }
+ className={`w-full py-2 text-sm ${
+ planOption === PlanEnum.Business
+ ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
+ : "bg-gray-800 text-white hover:bg-gray-900 dark:hover:bg-gray-700/80"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ setSelectedPlan(planOption);
+ if (isCustomer && teamPlan !== "free") {
+ fetch(
+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
+ {
+ method: "POST",
+ },
+ )
+ .then(async (res) => {
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ } else {
+ fetch(
+ `/api/teams/${
+ teamInfo?.currentTeam?.id
+ }/billing/upgrade?priceId=${
+ PLANS.find((p) => p.name === planOption)!.price[
+ period
+ ].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"]
+ }`,
+ {
+ 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 ${planOption} ${capitalize(period)}`}
+ </Button>
+ </div>
</div>
- </div>
- ))}
+ );
+ })}
</div>
<div className="mt-8 flex flex-col items-center space-y-2">