Skip to content

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

feat:updates

Iuliia Shnai2e94436eb922
diff --git a/components/analytics/time-range-select.tsx b/components/analytics/time-range-select.tsx
index f343dd3f..088fcfb3 100644
--- a/components/analytics/time-range-select.tsx
+++ b/components/analytics/time-range-select.tsx
@@ -16,7 +16,7 @@ import {
import { cn } from "@/lib/utils";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
const TIME_RANGES = [
{ value: "24h", label: "Last 24 hours", shortcut: "D" },
@@ -215,7 +215,7 @@ const UpgradeButton = () => {
>
Custom Date <CrownIcon className="!size-4" />
</Button>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger="dashboard_time_range_custom_select"
open={open}
diff --git a/components/billing/add-seat-modal.tsx b/components/billing/add-seat-modal.tsx
index c3b17e9a..2a65bfa0 100644
--- a/components/billing/add-seat-modal.tsx
+++ b/components/billing/add-seat-modal.tsx
@@ -186,7 +186,7 @@ export function AddSeatModal({
{loading ? "Redirecting..." : "Proceed to checkout"}
</Button>
<Link
- href="/settings/upgrade"
+ href="/settings/upgrade-holiday-offer"
className="block w-full text-center text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground"
onClick={() => setOpen(false)}
>
diff --git a/components/billing/pro-banner.tsx b/components/billing/pro-banner.tsx
index 3e7fe4e9..222425fd 100644
--- a/components/billing/pro-banner.tsx
+++ b/components/billing/pro-banner.tsx
@@ -6,7 +6,7 @@ import Cookies from "js-cookie";
import X from "@/components/shared/icons/x";
import { Button } from "@/components/ui/button";
-import { UpgradePlanModal } from "./upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "./upgrade-plan-modal-with-discount";
export default function ProBanner({
setShowProBanner,
@@ -37,14 +37,14 @@ export default function ProBanner({
Upgrade to unlock custom branding, team members, domains and data rooms.
</p>
<div className="flex">
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Business}
trigger={"pro_banner"}
>
<Button type="button" className="grow">
Upgrade
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
</div>
</aside>
);
diff --git a/components/billing/upgrade-plan-container.tsx b/components/billing/upgrade-plan-container.tsx
index 5e73763b..88e61dfe 100644
--- a/components/billing/upgrade-plan-container.tsx
+++ b/components/billing/upgrade-plan-container.tsx
@@ -201,7 +201,7 @@ export default function UpgradePlanContainer() {
clickedPlan={PlanEnum.Business}
trigger="upgrade_plan"
useModal={false}
- onClick={() => router.push("/settings/upgrade")}
+ onClick={() => router.push("/settings/upgrade-holiday-offer")}
/>
{isCustomer && (
<DropdownMenu>
diff --git a/components/billing/upgrade-plan-modal-with-discount.tsx b/components/billing/upgrade-plan-modal-with-discount.tsx
new file mode 100644
index 00000000..b8c6c2e1
--- /dev/null
+++ b/components/billing/upgrade-plan-modal-with-discount.tsx
@@ -0,0 +1,523 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+
+import { useEffect, useMemo, useState } from "react";
+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 { getPriceIdFromPlan } from "@/ee/stripe/functions/get-price-id-from-plan";
+import { PLANS } from "@/ee/stripe/utils";
+import { CheckIcon, CircleHelpIcon, Users2Icon, XIcon, Sparkles } from "lucide-react";
+
+import { useAnalytics } from "@/lib/analytics";
+import { usePlan } from "@/lib/swr/use-billing";
+import { capitalize, cn } from "@/lib/utils";
+
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
+import { Switch } from "@/components/ui/switch";
+import {
+ BadgeTooltip,
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+
+// Start Data Room Trial Button Component
+const StartDataRoomTrialButton = ({ teamId }: { teamId?: string }) => {
+ const router = useRouter();
+
+ const handleStartTrial = () => {
+ router.push("/welcome?type=dataroom-trial");
+ };
+
+ return (
+ <span
+ onClick={handleStartTrial}
+ className="cursor-pointer underline underline-offset-4 hover:text-foreground"
+ >
+ Start free data room trial
+ </span>
+ );
+};
+
+// 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">
+ {feature.isNotIncluded ? (
+ <XIcon className="h-5 w-5 flex-shrink-0 text-gray-500" />
+ ) : (
+ <CheckIcon className="h-5 w-5 flex-shrink-0 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>
+ );
+ }
+
+ return (
+ <div className={cn("text-sm", baseClasses)}>
+ {feature.isNotIncluded ? (
+ <XIcon className="mr-3 h-5 w-5 flex-shrink-0 text-gray-500" />
+ ) : (
+ <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-[#fb7a00]" />
+ )}
+ <div className="flex items-center gap-2">
+ <span>{feature.text}</span>
+ {feature.tooltip && (
+ <BadgeTooltip content={feature.tooltip}>
+ <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
+ </BadgeTooltip>
+ )}
+ </div>
+ </div>
+ );
+};
+
+// Segmented control component for Base/Plus/Premium selection
+const PlanSelector = ({
+ value,
+ onChange,
+}: {
+ value: "base" | "plus" | "premium";
+ onChange: (value: "base" | "plus" | "premium") => void;
+}) => {
+ return (
+ <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",
+ value === "base"
+ ? "bg-gray-300 text-foreground dark:bg-gray-600 dark:text-white"
+ : "text-gray-600 hover:text-gray-900 dark:text-muted-foreground dark:hover:text-white",
+ )}
+ onClick={() => onChange("base")}
+ >
+ Base
+ </button>
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ value === "plus"
+ ? "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={() => onChange("plus")}
+ >
+ Plus
+ </button>
+ <button
+ className={cn(
+ "flex-1 rounded-md px-3 py-1 text-sm transition-colors",
+ value === "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={() => onChange("premium")}
+ >
+ Premium
+ </button>
+ </div>
+ );
+};
+
+export function UpgradePlanModalWithDiscount({
+ clickedPlan,
+ trigger,
+ open,
+ setOpen,
+ highlightItem,
+ children,
+}: {
+ clickedPlan: PlanEnum;
+ trigger?: string;
+ open?: boolean;
+ setOpen?: React.Dispatch<React.SetStateAction<boolean>>;
+ highlightItem?: string[];
+ children?: React.ReactNode;
+}) {
+ const router = useRouter();
+ const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");
+ const [selectedPlan, setSelectedPlan] = useState<string | null>(null);
+ const teamInfo = useTeam();
+ const teamId = teamInfo?.currentTeam?.id;
+ const { plan: teamPlan, isCustomer, isOldAccount, isTrial, isFree } = usePlan();
+ const analytics = useAnalytics();
+ const [dataRoomsPlanSelection, setDataRoomsPlanSelection] = useState<
+ "base" | "plus" | "premium"
+ >("base");
+
+ // Get next higher plan for current user
+ const getNextHigherPlan = () => {
+ if (isFree) return PlanEnum.Pro; // Free users see Pro as next
+ if (teamPlan === "pro") return PlanEnum.Business;
+ if (teamPlan === "business") return PlanEnum.DataRooms;
+ if (teamPlan === "datarooms") return PlanEnum.DataRoomsPlus;
+ if (teamPlan === "datarooms-plus") return PlanEnum.DataRoomsPremium;
+ return null;
+ };
+
+ const nextHigherPlan = getNextHigherPlan();
+
+ const plansToShow = useMemo(() => {
+ switch (clickedPlan) {
+ 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.DataRoomsPlus, PlanEnum.DataRoomsPremium];
+ case PlanEnum.DataRoomsPremium:
+ return [PlanEnum.DataRoomsPlus, PlanEnum.DataRoomsPremium];
+ default:
+ return [PlanEnum.Pro, PlanEnum.Business];
+ }
+ }, [clickedPlan]);
+
+ // Track analytics event when modal is opened
+ useEffect(() => {
+ if (open) {
+ analytics.capture("Upgrade Button Clicked", {
+ trigger: trigger,
+ teamId,
+ });
+ } else {
+ setDataRoomsPlanSelection("base");
+ }
+ }, [open, trigger]);
+
+ const handleUpgradeClick = () => {
+ analytics.capture("Upgrade Button Clicked", {
+ trigger: trigger,
+ teamId,
+ });
+ };
+
+ // If button is present, clone it and add onClick handler
+ const buttonChild = React.isValidElement<{
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
+ }>(children)
+ ? React.cloneElement(children, { onClick: handleUpgradeClick })
+ : children;
+
+ // Calculate discount percentages
+ const calculateDiscount = (monthlyPrice: number, yearlyPrice: number) => {
+ return Math.round(((monthlyPrice - yearlyPrice) / monthlyPrice) * 100);
+ };
+
+ // Calculate 30% discounted yearly price
+ const getDiscountedYearlyPrice = (yearlyPrice: number) => {
+ return Math.round(yearlyPrice * 0.7); // Round to whole number
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogTrigger asChild>{buttonChild}</DialogTrigger>
+ <DialogContent
+ className="max-h-[90vh] min-h-fit overflow-y-auto bg-white text-foreground dark:bg-gray-900 p-0"
+ style={{
+ width: "95vw",
+ maxWidth: "1200px",
+ }}
+ >
+ <div className="flex flex-col lg:flex-row">
+ {/* Left Sidebar - Discount Information */}
+ <div className="flex h-full flex-col w-full 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>
+ <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]">HOLIDAY</p>
+ <div className="h-px flex-1 bg-[#fb7a00]"></div>
+ </div>
+ <p className="mt-2 text-xs text-gray-600 dark:text-gray-400">
+ Limited time 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 Dec 31 2025
+ </p>
+ </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>
+ </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]"
+ : displayPlanName === PlanEnum.DataRoomsPremium
+ ? "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">
+ {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 px-2 py-1 text-xs font-medium text-[#fb7a00] bg-[#fb7a00]/10">
+ Save €{savings}/year
+ </span>
+ ) : null;
+ })()}
+ {period === "monthly" && isOrangePlan && (
+ <span className="absolute right-2 top-2 rounded px-2 py-1 text-xs text-white bg-[#fb7a00]">
+ {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}
+ </span>
+ </div>
+ <span className="text-gray-500 dark:text-white/75">
+ /month
+ </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}
+ </span>
+ </div>
+ <span className="text-gray-500 dark:text-white/75">
+ /month
+ </span>
+ </>
+ )}
+ </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-muted-foreground">
+ {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:hover:bg-gray-700/80"
+ }`}
+ 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) => {
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(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) => {
+ 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 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>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
diff --git a/components/billing/yearly-upgrade-banner.tsx b/components/billing/yearly-upgrade-banner.tsx
new file mode 100644
index 00000000..531fb498
--- /dev/null
+++ b/components/billing/yearly-upgrade-banner.tsx
@@ -0,0 +1,199 @@
+"use client";
+
+import { Dispatch, SetStateAction, useState } from "react";
+import { useRouter } from "next/router";
+
+import { useTeam } from "@/context/team-context";
+import { getPriceIdFromPlan } from "@/ee/stripe/functions/get-price-id-from-plan";
+import { PlanEnum, getPlanFeatures } from "@/ee/stripe/constants";
+import { PLANS } from "@/ee/stripe/utils";
+import Cookies from "js-cookie";
+import { X, Sparkles, CheckIcon } from "lucide-react";
+import { motion, AnimatePresence } from "motion/react";
+
+import { usePlan } from "@/lib/swr/use-billing";
+import { cn } from "@/lib/utils";
+
+import { Button } from "@/components/ui/button";
+import { UpgradePlanModalWithDiscount } from "./upgrade-plan-modal-with-discount";
+
+interface YearlyUpgradeBannerProps {
+ setShowBanner: Dispatch<SetStateAction<boolean | null>>;
+}
+
+export default function YearlyUpgradeBanner({
+ setShowBanner,
+}: YearlyUpgradeBannerProps) {
+ const router = useRouter();
+ const teamInfo = useTeam();
+ const { plan: teamPlan, isAnnualPlan, isCustomer, isOldAccount } = usePlan();
+ const [isLoading, setIsLoading] = useState(false);
+
+ const handleHideBanner = () => {
+ setShowBanner(false);
+ Cookies.set("hideYearlyUpgradeBanner", "yearly-upgrade-banner", {
+ expires: 7,
+ });
+ };
+
+ // Calculate 30% discounted yearly price (same as modal)
+ const getDiscountedYearlyPrice = (yearlyPrice: number) => {
+ return Math.round(yearlyPrice * 0.7); // Round to whole number
+ };
+
+ // Get next higher plan
+ const getNextPlan = () => {
+ if (teamPlan === "pro") return PlanEnum.Business;
+ if (teamPlan === "business") return PlanEnum.DataRooms;
+ if (teamPlan === "datarooms") return PlanEnum.DataRoomsPlus;
+ if (teamPlan === "datarooms-plus") return PlanEnum.DataRoomsPremium;
+ return null;
+ };
+
+ const nextPlan = getNextPlan();
+
+ if (!nextPlan) return null; // Don't show banner if no next plan
+
+ const handleUpgradeToYearly = (planName: string) => {
+ if (!isCustomer) return;
+
+ const planData = PLANS.find((p) => p.name === planName);
+ if (!planData) return;
+
+ setIsLoading(true);
+ fetch(`/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ priceId: getPriceIdFromPlan({
+ planSlug: planData.slug,
+ isOld: isOldAccount,
+ period: "yearly",
+ }),
+ upgradePlan: true,
+ applyYearlyDiscount: true, // Apply 30% discount
+ yearlyUpgradeBanner: true,
+ }),
+ })
+ .then(async (res) => {
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ console.error(err);
+ })
+ .finally(() => {
+ setIsLoading(false);
+ });
+ };
+
+ return (
+ <AnimatePresence>
+ <motion.aside
+ initial={{ x: 400, opacity: 0 }}
+ animate={{ x: 0, opacity: 1 }}
+ exit={{ x: 400, opacity: 0 }}
+ transition={{ type: "spring", damping: 25, stiffness: 200 }}
+ className={cn(
+ "fixed right-0 top-1/2 z-50 w-80 -translate-y-1/2 rounded-l-lg border-l border-t border-b border-gray-200 bg-white p-6 shadow-xl dark:border-gray-800 dark:bg-gray-900",
+ )}
+ >
+ <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"
+ >
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </button>
+
+ <div className="mb-4 flex items-center gap-2">
+ <Sparkles className="h-5 w-5 text-black]" />
+ <span className="text-lg font-bold text-black">LIMITED TIME OFFER</span>
+ </div>
+
+ <div className="mb-2">
+ <p className="text-xs text-gray-500 dark:text-gray-400">
+ Extra 30% off on yearly plans
+ </p>
+ </div>
+
+ {/* Next Plan Card - Orange */}
+ {(() => {
+ const planData = PLANS.find((p) => p.name === nextPlan);
+ if (!planData) return null;
+
+ const yearlyPrice = planData.price.yearly.amount;
+ const discountedYearlyPrice = getDiscountedYearlyPrice(yearlyPrice);
+ const monthlyPrice = planData.price.monthly.amount;
+ const monthlyForYear = monthlyPrice * 12;
+ const yearlyWithDiscount = Math.round(yearlyPrice * 12 * 0.7);
+ const savings = monthlyForYear - yearlyWithDiscount;
+ const planFeatures = getPlanFeatures(nextPlan, { period: "yearly", maxFeatures: 4 });
+
+ return (
+ <div className="rounded-lg border-2 border-[#fb7a00] bg-orange-50 p-3 dark:bg-orange-900/20">
+ <div className="mb-1 flex items-center justify-between">
+ <span className="text-xs font-bold text-[#fb7a00]">
+ RECOMMENDED
+ </span>
+ {savings > 0 && (
+ <span className="text-xs font-medium text-[#fb7a00]">
+ Save €{savings}/year
+ </span>
+ )}
+ </div>
+ <p className="mb-1 text-sm font-semibold text-gray-900 dark:text-white">
+ {nextPlan} plan
+ </p>
+ <div className="mb-3 flex items-baseline gap-2">
+ <span className="text-2xl font-semibold text-gray-900 dark:text-white">
+ €{discountedYearlyPrice}
+ </span>
+ <span className="text-sm text-gray-500 line-through">
+ €{yearlyPrice}
+ </span>
+ <span className="text-xs text-gray-600 dark:text-gray-400">
+ /mo
+ </span>
+ </div>
+
+ {/* Features */}
+ <ul className="mb-3 space-y-1.5 text-xs text-gray-700 dark:text-gray-300">
+ {planFeatures.features.slice(0, 4).map((feature, i) => (
+ <li key={i} className="flex items-center gap-2">
+ <CheckIcon className="h-3.5 w-3.5 flex-shrink-0 text-[#fb7a00]" />
+ <span className="leading-tight">{feature.text}</span>
+ </li>
+ ))}
+ </ul>
+
+ <UpgradePlanModalWithDiscount clickedPlan={nextPlan} trigger="yearly_upgrade_banner">
+ <Button
+ type="button"
+ size="sm"
+ className="w-full bg-[#fb7a00] text-white hover:bg-[#fb7a00]/90 py-3 leading-tight"
+ >
+ Upgrade to {nextPlan} Yearly
+ </Button>
+ </UpgradePlanModalWithDiscount>
+ </div>
+ );
+ })()}
+
+ <p
+ onClick={() => router.push("/settings/upgrade-holiday-offer")}
+ className="mt-4 cursor-pointer text-center text-xs text-gray-500 dark:text-gray-400 underline hover:text-gray-600 dark:hover:text-gray-300"
+ >
+ Compare all plans
+ </p>
+ <p className="mt-2 text-center text-xs text-gray-500 dark:text-gray-400">
+ Limited time offer • Ends Dec 31
+ </p>
+ </motion.aside>
+ </AnimatePresence>
+ );
+}
+
diff --git a/components/datarooms/actions/generate-index-dialog.tsx b/components/datarooms/actions/generate-index-dialog.tsx
index ed5eaddc..54376456 100644
--- a/components/datarooms/actions/generate-index-dialog.tsx
+++ b/components/datarooms/actions/generate-index-dialog.tsx
@@ -14,7 +14,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useDataroomLinks } from "@/lib/swr/use-dataroom";
import { IndexFileFormat } from "@/lib/types/index-file";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -224,12 +224,12 @@ export default function GenerateIndexDialog({
{isLoading ? "Generating..." : "Generate"}
</Button>
) : (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms_generate_index_button"
>
<Button>Upgrade to generate</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</DialogFooter>
</DialogContent>
diff --git a/components/datarooms/actions/rebuild-index-button.tsx b/components/datarooms/actions/rebuild-index-button.tsx
index 69eeb9ec..55d285fc 100644
--- a/components/datarooms/actions/rebuild-index-button.tsx
+++ b/components/datarooms/actions/rebuild-index-button.tsx
@@ -7,7 +7,7 @@ import { toast } from "sonner";
import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { usePlan } from "@/lib/swr/use-billing";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -150,13 +150,13 @@ export default function RebuildIndexButton({
</Button>
</>
) : (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRoomsPlus}
trigger="datarooms_rebuild_index_button"
highlightItem={["indexing"]}
>
<Button>Upgrade to rebuild index</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</DialogFooter>
</DialogContent>
diff --git a/components/datarooms/add-dataroom-modal.tsx b/components/datarooms/add-dataroom-modal.tsx
index 73bfc0b8..664797db 100644
--- a/components/datarooms/add-dataroom-modal.tsx
+++ b/components/datarooms/add-dataroom-modal.tsx
@@ -55,7 +55,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";
import { Checkbox } from "@/components/ui/checkbox";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
export function AddDataroomModal({
children,
@@ -348,12 +348,12 @@ export function AddDataroomModal({
if (isFree || isPro) {
if (children) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger={"add_dataroom_overview"}
>
{children}
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
}
}
diff --git a/components/datarooms/dataroom-trial-modal.tsx b/components/datarooms/dataroom-trial-modal.tsx
index 3b394e07..8eb4c5a5 100644
--- a/components/datarooms/dataroom-trial-modal.tsx
+++ b/components/datarooms/dataroom-trial-modal.tsx
@@ -23,7 +23,7 @@ import {
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { PhoneInput } from "../ui/phone-input";
import {
Select,
@@ -259,9 +259,9 @@ export function DataroomTrialModal({
<div className="text-xs text-muted-foreground">
After the trial, upgrade to{" "}
- <UpgradePlanModal clickedPlan={PlanEnum.Business}>
+ <UpgradePlanModalWithDiscount clickedPlan={PlanEnum.Business}>
<button className="underline">Papermark Business</button>
- </UpgradePlanModal>{" "}
+ </UpgradePlanModalWithDiscount>{" "}
to continue using data rooms.
</div>
</div>
diff --git a/components/datarooms/settings/dataroom-tag-section.tsx b/components/datarooms/settings/dataroom-tag-section.tsx
index 1e109d3c..6d415169 100644
--- a/components/datarooms/settings/dataroom-tag-section.tsx
+++ b/components/datarooms/settings/dataroom-tag-section.tsx
@@ -11,7 +11,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useTags } from "@/lib/swr/use-tags";
import { TagColorProps } from "@/lib/types";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -225,7 +225,7 @@ export default function DataroomTagSection({
</CardFooter>
</Card>
{showUpgradeModal && (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger="create_tag"
open={showUpgradeModal}
diff --git a/components/datarooms/settings/duplicate-dataroom.tsx b/components/datarooms/settings/duplicate-dataroom.tsx
index 5c0487e2..ead32b0d 100644
--- a/components/datarooms/settings/duplicate-dataroom.tsx
+++ b/components/datarooms/settings/duplicate-dataroom.tsx
@@ -7,7 +7,7 @@ import { PlanEnum } from "@/ee/stripe/constants";
import { toast } from "sonner";
import { mutate } from "swr";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -129,7 +129,7 @@ export default function DuplicateDataroom({
</CardFooter>
</Card>
{planModalOpen ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
open={planModalOpen}
diff --git a/components/document-upload.tsx b/components/document-upload.tsx
index c12f63dc..82c0b166 100644
--- a/components/document-upload.tsx
+++ b/components/document-upload.tsx
@@ -69,7 +69,7 @@ export default function DocumentUpload({
description: "Upgrade to a paid plan to increase the limit",
action: {
label: "Upgrade",
- onClick: () => router.push("/settings/upgrade"),
+ onClick: () => router.push("/settings/upgrade-holiday-offer"),
},
duration: 10000,
});
@@ -112,7 +112,7 @@ export default function DocumentUpload({
description: "Upgrade to a paid plan to increase the limit",
action: {
label: "Upgrade",
- onClick: () => router.push("/settings/upgrade"),
+ onClick: () => router.push("/settings/upgrade-holiday-offer"),
},
duration: 10000,
});
@@ -126,7 +126,7 @@ export default function DocumentUpload({
description: `Upgrade to a paid plan to upload ${file.type} files`,
action: {
label: "Upgrade",
- onClick: () => router.push("/settings/upgrade"),
+ onClick: () => router.push("/settings/upgrade-holiday-offer"),
},
duration: 10000,
});
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsx
index b1215d64..06e36f68 100644
--- a/components/documents/add-document-modal.tsx
+++ b/components/documents/add-document-modal.tsx
@@ -45,7 +45,7 @@ import {
import { Label } from "@/components/ui/label";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
interface DataroomDocument {
id: string;
@@ -534,21 +534,21 @@ export function AddDocumentModal({
if (!canAddDocuments && children) {
if (newVersion) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger={"limit_upload_document_version"}
>
{children}
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
}
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger={"limit_upload_documents"}
>
<Button>Upgrade to Add Documents</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
}
diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsx
index 39d69238..774a2d0e 100644
--- a/components/documents/document-card.tsx
+++ b/components/documents/document-card.tsx
@@ -27,7 +27,7 @@ import { cn, getBreadcrumbPath, nFormatter, timeAgo } from "@/lib/utils";
import { fileIcon } from "@/lib/utils/get-file-icon";
import { useCopyToClipboard } from "@/lib/utils/use-copy-to-clipboard";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { DataroomTrialModal } from "@/components/datarooms/dataroom-trial-modal";
import { AddToDataroomModal } from "@/components/documents/add-document-to-dataroom-modal";
import { DocumentPreviewModal } from "@/components/documents/document-preview-modal";
@@ -421,7 +421,7 @@ export default function DocumentsCard({
/>
) : null}
{planModalOpen ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
open={planModalOpen}
diff --git a/components/documents/document-header.tsx b/components/documents/document-header.tsx
index 8878d798..3cc6ed21 100644
--- a/components/documents/document-header.tsx
+++ b/components/documents/document-header.tsx
@@ -58,7 +58,7 @@ import {
} from "@/components/ui/dropdown-menu";
import PlanBadge from "../billing/plan-badge";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import AdvancedSheet from "../shared/icons/advanced-sheet";
import PortraitLandscape from "../shared/icons/portrait-landscape";
import LoadingSpinner from "../ui/loading-spinner";
@@ -991,7 +991,7 @@ export default function DocumentHeader({
) : null}
{planModalOpen ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={selectedPlan}
trigger={planModalTrigger}
open={planModalOpen}
diff --git a/components/domains/add-domain-modal.tsx b/components/domains/add-domain-modal.tsx
index 1713e562..d2f4efdc 100644
--- a/components/domains/add-domain-modal.tsx
+++ b/components/domains/add-domain-modal.tsx
@@ -23,7 +23,7 @@ import {
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { UpgradeButton } from "../ui/upgrade-button";
export function AddDomainModal({
@@ -131,7 +131,7 @@ export function AddDomainModal({
);
} else {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={
linkType === "DATAROOM_LINK"
? PlanEnum.DataRooms
diff --git a/components/emails/custom-domain-setup.tsx b/components/emails/custom-domain-setup.tsx
index 2fc095bb..6481de4e 100644
--- a/components/emails/custom-domain-setup.tsx
+++ b/components/emails/custom-domain-setup.tsx
@@ -100,7 +100,7 @@ export default function CustomDomainSetup({
) : (
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
- href={`https://app.papermark.com/settings/upgrade`}
+ href={`https://app.papermark.com/settings/upgrade-holiday-offer`}
style={{ padding: "12px 20px" }}
>
Upgrade to use custom domains
@@ -124,7 +124,7 @@ export default function CustomDomainSetup({
<>
Want to learn more about our plans?{" "}
<Link
- href="https://app.papermark.com/settings/upgrade"
+ href="https://app.papermark.com/settings/upgrade-holiday-offer"
className="font-medium text-blue-600 no-underline"
>
View pricing
diff --git a/components/folders/add-folder-modal.tsx b/components/folders/add-folder-modal.tsx
index 36d28295..88dc6573 100644
--- a/components/folders/add-folder-modal.tsx
+++ b/components/folders/add-folder-modal.tsx
@@ -25,7 +25,7 @@ import { Label } from "@/components/ui/label";
import { useAnalytics } from "@/lib/analytics";
import { usePlan } from "@/lib/swr/use-billing";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
export function AddFolderModal({
// open,
@@ -139,13 +139,13 @@ export function AddFolderModal({
if (isFree && !isTrial) {
if (children) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger={"add_folder_button"}
highlightItem={["folder", "multi-file"]}
>
{children}
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
}
}
diff --git a/components/layouts/app.tsx b/components/layouts/app.tsx
index 1895d702..a415db2b 100644
--- a/components/layouts/app.tsx
+++ b/components/layouts/app.tsx
@@ -1,4 +1,5 @@
import Cookies from "js-cookie";
+import { useEffect, useState } from "react";
import { AppBreadcrumb } from "@/components/layouts/breadcrumb";
import TrialBanner from "@/components/layouts/trial-banner";
@@ -11,6 +12,9 @@ import {
SidebarTrigger,
} from "@/components/ui/sidebar";
+import { usePlan } from "@/lib/swr/use-billing";
+import YearlyUpgradeBanner from "@/components/billing/yearly-upgrade-banner";
+
import { BlockingModal } from "./blocking-modal";
export default function AppLayout({ children }: { children: React.ReactNode }) {
@@ -19,6 +23,25 @@ export default function AppLayout({ children }: { children: React.ReactNode }) {
const isSidebarOpen =
cookieValue === undefined ? true : cookieValue === "true";
+ const { isAnnualPlan, isFree } = usePlan();
+ const [showYearlyBanner, setShowYearlyBanner] = useState<boolean | null>(null);
+
+ // Show banner only for paid monthly subscribers (not free, not yearly)
+ useEffect(() => {
+ // Hide banner for free users or yearly subscribers
+ if (isFree || isAnnualPlan) {
+ setShowYearlyBanner(false);
+ return;
+ }
+
+ // Show banner for monthly paid users (if not dismissed)
+ if (Cookies.get("hideYearlyUpgradeBanner") !== "yearly-upgrade-banner") {
+ setShowYearlyBanner(true);
+ } else {
+ setShowYearlyBanner(false);
+ }
+ }, [isFree, isAnnualPlan]);
+
return (
<SidebarProvider defaultOpen={isSidebarOpen}>
<div className="flex flex-1 flex-col gap-x-1 bg-gray-50 dark:bg-black md:flex-row">
@@ -36,6 +59,9 @@ export default function AppLayout({ children }: { children: React.ReactNode }) {
<main className="flex-1">{children}</main>
</SidebarInset>
</div>
+ {showYearlyBanner && (
+ <YearlyUpgradeBanner setShowBanner={setShowYearlyBanner} />
+ )}
</SidebarProvider>
);
}
diff --git a/components/layouts/blocking-modal.tsx b/components/layouts/blocking-modal.tsx
index f2bd4f0c..ed2d11cf 100644
--- a/components/layouts/blocking-modal.tsx
+++ b/components/layouts/blocking-modal.tsx
@@ -22,7 +22,7 @@ import {
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { AddTeamModal } from "../teams/add-team-modal";
export const BlockingModal = () => {
@@ -129,14 +129,14 @@ export const BlockingModal = () => {
plan.
</p>
</div>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger="trial_end_blocking_modal"
>
<Button type="button" variant="orange">
Upgrade
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
<Button type="button" variant="outline">
Dismiss
</Button>
@@ -181,14 +181,14 @@ export const BlockingModal = () => {
>
Log out
</Button>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Business}
trigger="trial_end_blocking_modal_for_team_member"
>
<Button className="w-full sm:w-auto" type="button">
Upgrade
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
{userTeam ? (
<Button
variant="outline"
diff --git a/components/layouts/trial-banner.tsx b/components/layouts/trial-banner.tsx
index 81671e6d..e9b447b6 100644
--- a/components/layouts/trial-banner.tsx
+++ b/components/layouts/trial-banner.tsx
@@ -9,7 +9,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import useDatarooms from "@/lib/swr/use-datarooms";
import { daysLeft } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import {
Alert,
AlertClose,
@@ -83,14 +83,14 @@ function TrialBannerComponent({
<AlertDescription>
{isExpired ? (
<>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger={"trial_navbar"}
>
<span className="cursor-pointer font-bold text-black underline underline-offset-4 hover:text-gray-700 dark:text-white dark:hover:text-gray-300">
Upgrade to keep access
</span>
- </UpgradePlanModal>{" "}
+ </UpgradePlanModalWithDiscount>{" "}
to unlimited data rooms, custom domains, advanced access controls,
and granular file permissions ✨
</>
@@ -99,14 +99,14 @@ function TrialBannerComponent({
You are on the <span className="font-bold">Data Rooms</span> plan
trial, you have access to advanced access controls, granular file
permissions, and data room. <br />
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger={"trial_navbar"}
>
<span className="cursor-pointer font-bold text-orange-500 underline underline-offset-4 hover:text-orange-600">
Upgrade to keep access
</span>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
, unlock unlimited data rooms and custom domains ✨
</>
)}
diff --git a/components/links/link-sheet/domain-section.tsx b/components/links/link-sheet/domain-section.tsx
index abd73f68..dec8826b 100644
--- a/components/links/link-sheet/domain-section.tsx
+++ b/components/links/link-sheet/domain-section.tsx
@@ -12,7 +12,7 @@ import { BasePlan, usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
import { cn } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { AddDomainModal } from "@/components/domains/add-domain-modal";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -313,7 +313,7 @@ export default function DomainSection({
/>
{/* Upgrade plan modal when trying to use custom domains without the right plan */}
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={
linkType === "DATAROOM_LINK" ? PlanEnum.DataRooms : PlanEnum.Business
}
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index cc2305c1..4ae08c0a 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -19,7 +19,7 @@ import useLimits from "@/lib/swr/use-limits";
import { LinkWithViews, WatermarkConfig } from "@/lib/types";
import { convertDataUrlToFile, fetcher, uploadImage } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -496,14 +496,14 @@ export default function LinkSheet({
Group
</TabsTrigger>
) : (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="add_group_link"
>
<div className="inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all">
Group
</div>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</TabsList>
) : null}
diff --git a/components/links/link-sheet/link-options.tsx b/components/links/link-sheet/link-options.tsx
index c26e29bd..47a0b1be 100644
--- a/components/links/link-sheet/link-options.tsx
+++ b/components/links/link-sheet/link-options.tsx
@@ -9,7 +9,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
import { cn } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
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";
@@ -298,7 +298,7 @@ export const LinkOptions = ({
</div>
</CollapsibleSection>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={upgradePlan}
open={openUpgradeModal}
setOpen={setOpenUpgradeModal}
diff --git a/components/links/link-sheet/tags/tag-section.tsx b/components/links/link-sheet/tags/tag-section.tsx
index b8ca02f3..fc81c3ab 100644
--- a/components/links/link-sheet/tags/tag-section.tsx
+++ b/components/links/link-sheet/tags/tag-section.tsx
@@ -11,7 +11,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useTags } from "@/lib/swr/use-tags";
import { TagProps } from "@/lib/types";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Label } from "@/components/ui/label";
import { MultiSelect } from "@/components/ui/multi-select-v2";
import { BadgeTooltip } from "@/components/ui/tooltip";
@@ -145,7 +145,7 @@ export default function TagSection({
/>
</div>
{showUpgradeModal && (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger="create_tag"
open={showUpgradeModal}
diff --git a/components/links/links-table.tsx b/components/links/links-table.tsx
index 42a61624..f84e9078 100644
--- a/components/links/links-table.tsx
+++ b/components/links/links-table.tsx
@@ -31,7 +31,7 @@ import { LinkWithViews, WatermarkConfig } from "@/lib/types";
import { cn, copyToClipboard, nFormatter, timeAgo } from "@/lib/utils";
import { useMediaQuery } from "@/lib/utils/use-media-query";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Collapsible,
@@ -524,12 +524,12 @@ export default function LinksTable({
const AddLinkButton = () => {
if (!canAddLinks) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={isTrial ? PlanEnum.Business : PlanEnum.Pro}
trigger={"limit_add_link"}
>
<Button>Upgrade to Create Link</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
} else {
return (
diff --git a/components/navigation-menu.tsx b/components/navigation-menu.tsx
index 6761022e..a1842ff2 100644
--- a/components/navigation-menu.tsx
+++ b/components/navigation-menu.tsx
@@ -12,7 +12,7 @@ import { cn } from "@/lib/utils";
import { Separator } from "@/components/ui/separator";
-import { UpgradePlanModal } from "./billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "./billing/upgrade-plan-modal-with-discount";
type Props = {
navigation: {
@@ -99,7 +99,7 @@ const NavItem: React.FC<Props["navigation"][0]> = ({
)}
>
{limited ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
key={label}
clickedPlan={PlanEnum.DataRoomsPlus}
trigger={label}
@@ -109,7 +109,7 @@ const NavItem: React.FC<Props["navigation"][0]> = ({
{label}
<CrownIcon className="h-4 w-4 text-muted-foreground" />
</div>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
) : (
<Link
href={href}
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsx
index 737d5d36..f89d97e1 100644
--- a/components/sidebar/app-sidebar.tsx
+++ b/components/sidebar/app-sidebar.tsx
@@ -40,7 +40,6 @@ import {
SidebarMenuItem,
} from "@/components/ui/sidebar";
-import ProAnnualBanner from "../billing/pro-annual-banner";
import ProBanner from "../billing/pro-banner";
import { Progress } from "../ui/progress";
import SlackBanner from "./banners/slack-banner";
@@ -48,9 +47,6 @@ import SlackBanner from "./banners/slack-banner";
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
const router = useRouter();
const [showProBanner, setShowProBanner] = useState<boolean | null>(null);
- const [showProAnnualBanner, setShowProAnnualBanner] = useState<
- boolean | null
- >(null);
const [showSlackBanner, setShowSlackBanner] = useState<boolean | null>(null);
const { currentTeam, teams, setCurrentTeam, isLoading }: TeamContextType =
useTeam() || initialState;
@@ -87,11 +83,6 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
} else {
setShowProBanner(false);
}
- if (Cookies.get("hideProAnnualBanner") !== "pro-annual-banner") {
- setShowProAnnualBanner(true);
- } else {
- setShowProAnnualBanner(false);
- }
if (Cookies.get("hideSlackBanner") !== "slack-banner") {
setShowSlackBanner(true);
} else {
@@ -299,14 +290,6 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
{isFree && showProBanner ? (
<ProBanner setShowProBanner={setShowProBanner} />
) : null}
- {/*
- * if user is pro and showProAnnualBanner is true show pro annual banner
- */}
- {isPro && !isAnnualPlan && showProAnnualBanner ? (
- <ProAnnualBanner
- setShowProAnnualBanner={setShowProAnnualBanner}
- />
- ) : null}
<div className="mb-2">
{linksLimit ? (
diff --git a/components/sidebar/nav-main.tsx b/components/sidebar/nav-main.tsx
index d96d5204..3c2d25bc 100644
--- a/components/sidebar/nav-main.tsx
+++ b/components/sidebar/nav-main.tsx
@@ -27,7 +27,7 @@ import {
SidebarMenuSubItem,
} from "@/components/ui/sidebar";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
export interface NavItem {
title: string;
@@ -78,7 +78,7 @@ export function NavMain({ items }: { items: NavItem[] }) {
)}
>
{item.disabled ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
key={item.title}
clickedPlan={item.plan as PlanEnum}
trigger={item.trigger}
@@ -94,7 +94,7 @@ export function NavMain({ items }: { items: NavItem[] }) {
<CrownIcon className="!size-4" />
</span>
</div>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
) : (
<Link
href={item.url}
diff --git a/components/sidebar/team-switcher.tsx b/components/sidebar/team-switcher.tsx
index c67cc9f1..3f290767 100644
--- a/components/sidebar/team-switcher.tsx
+++ b/components/sidebar/team-switcher.tsx
@@ -25,7 +25,7 @@ import {
} from "@/components/ui/sidebar";
import { AddSeatModal } from "../billing/add-seat-modal";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { AddTeamMembers } from "../teams/add-team-member-modal";
import { AddTeamModal } from "../teams/add-team-modal";
import { Avatar, AvatarFallback } from "../ui/avatar";
@@ -119,7 +119,7 @@ export function TeamSwitcher({
</DropdownMenuItem>
</AddTeamModal>
) : (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRoomsPremium}
trigger="add_new_team"
highlightItem={["teams"]}
@@ -133,14 +133,14 @@ export function TeamSwitcher({
</div>
<div className="font-medium text-muted-foreground">Add new team</div>
</DropdownMenuItem>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
<SidebarMenuItem>
{showUpgradePlanModal ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={isTrial ? PlanEnum.Business : PlanEnum.Pro}
trigger={"invite_team_members"}
>
@@ -150,7 +150,7 @@ export function TeamSwitcher({
>
<UserRoundPlusIcon className="!size-5" strokeWidth={1.5} />
</SidebarMenuButton>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
) : canAddUsers ? (
<AddTeamMembers
open={isTeamMemberInviteModalOpen}
diff --git a/components/tags/add-tag-modal.tsx b/components/tags/add-tag-modal.tsx
index 86eeef76..2829c504 100644
--- a/components/tags/add-tag-modal.tsx
+++ b/components/tags/add-tag-modal.tsx
@@ -6,7 +6,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { TagColorProps } from "@/lib/types";
import { cn } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -75,12 +75,12 @@ export function AddTagsModal({
if (isFree && tagCount >= 5) {
if (children) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={isTrial ? PlanEnum.Business : PlanEnum.Pro}
trigger={"create_tag"}
>
<Button>Upgrade to Create Tags</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
}
}
diff --git a/components/ui/upgrade-button.tsx b/components/ui/upgrade-button.tsx
index c2836d84..f2236879 100644
--- a/components/ui/upgrade-button.tsx
+++ b/components/ui/upgrade-button.tsx
@@ -5,7 +5,7 @@ import { CrownIcon } from "lucide-react";
import { cn } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
interface UpgradeButtonProps {
@@ -68,7 +68,7 @@ export function UpgradeButton({
return (
<>
{buttonContent}
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={clickedPlan}
trigger={trigger}
open={open}
diff --git a/components/visitors/visitor-useragent-placeholder.tsx b/components/visitors/visitor-useragent-placeholder.tsx
index 5eec66e9..2a4f8785 100644
--- a/components/visitors/visitor-useragent-placeholder.tsx
+++ b/components/visitors/visitor-useragent-placeholder.tsx
@@ -1,7 +1,7 @@
import { PlanEnum } from "@/ee/stripe/constants";
import { CrownIcon } from "lucide-react";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { Button } from "@/components/ui/button";
import UAIcon from "@/components/user-agent-icon";
@@ -37,7 +37,7 @@ export default function VisitorUserAgentPlaceholder() {
</div>
</div>
<div className="absolute left-8 top-3">
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Pro}
trigger="visitor-table-user-agent"
>
@@ -49,7 +49,7 @@ export default function VisitorUserAgentPlaceholder() {
<CrownIcon className="size-4" />
<span>See more visitor info</span>
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
</div>
</div>
);
diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsx
index dceaff5a..b64a6ab7 100644
--- a/components/visitors/visitors-table.tsx
+++ b/components/visitors/visitors-table.tsx
@@ -43,7 +43,7 @@ import {
import { TimestampTooltip } from "@/components/ui/timestamp-tooltip";
import { BadgeTooltip } from "@/components/ui/tooltip";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { Pagination } from "../documents/pagination";
import { Button } from "../ui/button";
import {
@@ -512,14 +512,14 @@ export default function VisitorsTable({
Some older views may not be shown because your document
has more than 20 views.{" "}
</span>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={isTrial ? PlanEnum.Business : PlanEnum.Pro}
trigger=""
>
<button className="underline hover:text-gray-800">
Upgrade to see full history
</button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
</div>
</TableCell>
</TableRow>
diff --git a/components/welcome/containers/onboarding-link-options.tsx b/components/welcome/containers/onboarding-link-options.tsx
index a7a25af3..6af64073 100644
--- a/components/welcome/containers/onboarding-link-options.tsx
+++ b/components/welcome/containers/onboarding-link-options.tsx
@@ -7,7 +7,7 @@ import { LinkPreset } from "@prisma/client";
import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { DEFAULT_LINK_TYPE } from "@/components/links/link-sheet";
import AgreementSection from "@/components/links/link-sheet/agreement-section";
import AllowDownloadSection from "@/components/links/link-sheet/allow-download-section";
@@ -262,7 +262,7 @@ export const OnboardingLinkOptions = ({
<div>
{basicSettings}
{showAdvancedSettings && advancedSettings}
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={upgradePlan}
open={openUpgradeModal}
setOpen={setOpenUpgradeModal}
diff --git a/components/welcome/dataroom-trial.tsx b/components/welcome/dataroom-trial.tsx
index 1472961e..c666f0aa 100644
--- a/components/welcome/dataroom-trial.tsx
+++ b/components/welcome/dataroom-trial.tsx
@@ -23,7 +23,7 @@ import {
SelectValue,
} from "@/components/ui/select";
-import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "../billing/upgrade-plan-modal-with-discount";
import { Input } from "../ui/input";
export default function DataroomTrial() {
@@ -324,18 +324,18 @@ export default function DataroomTrial() {
<div className="text-xs text-muted-foreground">
{/* Data rooms are available on our{" "}
- <UpgradePlanModal clickedPlan={PlanEnum.Business}>
+ <UpgradePlanModalWithDiscount clickedPlan={PlanEnum.Business}>
<button className="underline">Business</button>
- </UpgradePlanModal>{" "}
+ </UpgradePlanModalWithDiscount>{" "}
plan. <br /> */}
No credit card is required. After the trial, upgrade to{" "}
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Business}
highlightItem={["datarooms"]}
trigger="dataroom_trial_form"
>
<button className="underline">Papermark Data Rooms</button>
- </UpgradePlanModal>{" "}
+ </UpgradePlanModalWithDiscount>{" "}
to continue using data rooms.
</div>
</div>
diff --git a/ee/features/permissions/components/dataroom-link-sheet.tsx b/ee/features/permissions/components/dataroom-link-sheet.tsx
index 7aebc9d2..4f83688d 100644
--- a/ee/features/permissions/components/dataroom-link-sheet.tsx
+++ b/ee/features/permissions/components/dataroom-link-sheet.tsx
@@ -721,14 +721,14 @@ export function DataroomLinkSheet({
Group
</TabsTrigger>
) : (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="add_group_link"
>
<div className="inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all">
Group
</div>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</TabsList>
) : null} */}
diff --git a/ee/features/permissions/components/permissions-sheet.tsx b/ee/features/permissions/components/permissions-sheet.tsx
index 88185981..1261a0b2 100644
--- a/ee/features/permissions/components/permissions-sheet.tsx
+++ b/ee/features/permissions/components/permissions-sheet.tsx
@@ -35,7 +35,7 @@ import {
} from "@/lib/utils/hierarchical-display";
import PlanBadge from "@/components/billing/plan-badge";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import CloudDownloadOff from "@/components/shared/icons/cloud-download-off";
import { Button } from "@/components/ui/button";
import {
@@ -964,7 +964,7 @@ export function PermissionsSheet({
<div className="flex items-center gap-2">
<h4 className="text-sm font-medium">Share Entire Dataroom</h4>
{!canSetCustomPermissions && (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="dataroom_permissions_sheet_toggle"
>
@@ -974,7 +974,7 @@ export function PermissionsSheet({
>
<PlanBadge plan={PlanEnum.DataRooms} />
</button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
)}
</div>
<p className="text-sm text-muted-foreground">
diff --git a/pages/account/general.tsx b/pages/account/general.tsx
index ee8bcc81..528fe777 100644
--- a/pages/account/general.tsx
+++ b/pages/account/general.tsx
@@ -1,4 +1,5 @@
import { NextPage } from "next";
+import { useEffect, useState } from "react";
import { useSession } from "next-auth/react";
import { toast } from "sonner";
@@ -7,14 +8,43 @@ import { AccountHeader } from "@/components/account/account-header";
import UploadAvatar from "@/components/account/upload-avatar";
import AppLayout from "@/components/layouts/app";
import { Form } from "@/components/ui/form";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
+import { PlanEnum } from "@/ee/stripe/constants";
+import { usePlan } from "@/lib/swr/use-billing";
import { validateEmail } from "@/lib/utils/validate-email";
const ProfilePage: NextPage = () => {
const { data: session, update } = useSession();
+ const { plan: teamPlan, isAnnualPlan, isFree } = usePlan();
+ const [showUpgradeModal, setShowUpgradeModal] = useState(false);
+
+ // Determine the next plan to highlight
+ const getNextPlan = () => {
+ if (isFree) return PlanEnum.Pro;
+ if (teamPlan === "pro") return PlanEnum.Business;
+ if (teamPlan === "business") return PlanEnum.DataRooms;
+ return PlanEnum.Business; // Default
+ };
+
+ const nextPlan = getNextPlan();
+
+ // Show modal for monthly subscribers and free users when opening account
+ useEffect(() => {
+ if (!isAnnualPlan) {
+ // Show modal for monthly subscribers and free users
+ setShowUpgradeModal(true);
+ }
+ }, [isAnnualPlan]);
return (
<AppLayout>
+ <UpgradePlanModalWithDiscount
+ clickedPlan={nextPlan}
+ trigger="account_page"
+ open={showUpgradeModal}
+ setOpen={setShowUpgradeModal}
+ />
<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">
<AccountHeader />
<div className="space-y-6">
diff --git a/pages/api/teams/[teamId]/billing/manage.ts b/pages/api/teams/[teamId]/billing/manage.ts
index 93884671..8939b54b 100644
--- a/pages/api/teams/[teamId]/billing/manage.ts
+++ b/pages/api/teams/[teamId]/billing/manage.ts
@@ -1,9 +1,10 @@
import { NextApiRequest, NextApiResponse } from "next";
import { stripeInstance } from "@/ee/stripe";
+import { getCouponFromPlan } from "@/ee/stripe/functions/get-coupon-from-plan";
import { getQuantityFromPriceId } from "@/ee/stripe/functions/get-quantity-from-plan";
import getSubscriptionItem from "@/ee/stripe/functions/get-subscription-item";
-import { isOldAccount } from "@/ee/stripe/utils";
+import { getPlanFromPriceId, isOldAccount } from "@/ee/stripe/utils";
import { waitUntil } from "@vercel/functions";
import { getServerSession } from "next-auth/next";
@@ -42,6 +43,7 @@ export default async function handle(
addSeat,
proAnnualBanner,
return_url,
+ applyYearlyDiscount,
type = "manage",
} = req.body as {
priceId: string;
@@ -50,6 +52,7 @@ export default async function handle(
addSeat?: boolean;
proAnnualBanner?: boolean;
return_url?: string;
+ applyYearlyDiscount?: boolean;
type?:
| "manage"
| "invoices"
@@ -96,6 +99,39 @@ export default async function handle(
const minQuantity = getQuantityFromPriceId(priceId);
const stripe = stripeInstance(isOldAccount(team.plan));
+
+ // Apply 30% discount for yearly plans before redirecting to billing portal
+ // Same logic as retention flow: apply coupon directly to subscription
+ if (applyYearlyDiscount && upgradePlan) {
+ const plan = getPlanFromPriceId(priceId, isOldAccount(team.plan));
+ if (plan) {
+ // Use the same logic as retention flow: getCouponFromPlan(team.plan, isAnnualPlan)
+ // team.plan format is "pro", "business", "pro+old", "business+old", etc.
+ const planString = `${plan.slug}${isOldAccount(team.plan) ? "+old" : ""}`;
+ const couponId = getCouponFromPlan(planString, true);
+
+ // Verify coupon exists before applying (coupons might only exist in production, not test mode)
+ try {
+ await stripe.coupons.retrieve(couponId);
+ // Apply discount directly to subscription (same as retention flow)
+ await stripe.subscriptions.update(team.subscriptionId, {
+ discounts: [{ coupon: couponId }],
+ });
+ } catch (error: any) {
+ // If coupon doesn't exist (common in test mode), log and skip
+ if (error.code === "resource_missing") {
+ console.warn(
+ `[Manage] Coupon "${couponId}" not found in ${process.env.NEXT_PUBLIC_VERCEL_ENV || "test"} mode. ` +
+ `Skipping discount application. This is expected if the coupon only exists in production.`
+ );
+ } else {
+ // Re-throw other errors
+ throw error;
+ }
+ }
+ }
+ }
+
const { url } = await stripe.billingPortal.sessions.create({
customer: team.stripeId,
return_url: `${process.env.NEXTAUTH_URL}/settings/billing?cancel=true`,
diff --git a/pages/api/teams/[teamId]/billing/upgrade.ts b/pages/api/teams/[teamId]/billing/upgrade.ts
index 45449a34..a01102ca 100644
--- a/pages/api/teams/[teamId]/billing/upgrade.ts
+++ b/pages/api/teams/[teamId]/billing/upgrade.ts
@@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import { checkRateLimit, rateLimiters } from "@/ee/features/security";
import { stripeInstance } from "@/ee/stripe";
+import { getCouponFromPlan } from "@/ee/stripe/functions/get-coupon-from-plan";
import { getPlanFromPriceId, isOldAccount } from "@/ee/stripe/utils";
import { waitUntil } from "@vercel/functions";
import { getServerSession } from "next-auth/next";
@@ -45,9 +46,10 @@ export default async function handle(
return;
}
- const { teamId, priceId } = req.query as {
+ const { teamId, priceId, applyYearlyDiscount } = req.query as {
teamId: string;
priceId: string;
+ applyYearlyDiscount?: string;
};
const { id: userId, email: userEmail } = session.user as CustomUser;
@@ -80,6 +82,34 @@ export default async function handle(
const minimumQuantity = plan.minQuantity;
let stripeSession;
+ let couponId: string | undefined;
+
+ // Apply 30% coupon for yearly plans if requested (same as retention flow)
+ // Since the upgrade modal is yearly-only, if applyYearlyDiscount is true, always apply
+ if (applyYearlyDiscount === "true") {
+ // Use the same logic as retention flow: getCouponFromPlan(team.plan, isAnnualPlan)
+ // team.plan format is "pro", "business", "pro+old", "business+old", etc.
+ const planString = oldAccount ? `${plan.slug}+old` : plan.slug;
+ couponId = getCouponFromPlan(planString, true);
+
+ // Verify coupon exists in Stripe (coupons might only exist in production, not test mode)
+ const stripe = stripeInstance(oldAccount);
+ try {
+ await stripe.coupons.retrieve(couponId);
+ } catch (error: any) {
+ // If coupon doesn't exist (common in test mode), continue without discount
+ if (error.code === "resource_missing") {
+ console.warn(
+ `[Upgrade] Coupon "${couponId}" not found in ${process.env.NEXT_PUBLIC_VERCEL_ENV || "test"} mode. ` +
+ `Continuing without discount. This is expected if the coupon only exists in production.`
+ );
+ couponId = undefined;
+ } else {
+ // Re-throw other errors
+ throw error;
+ }
+ }
+ }
const lineItem = {
price: priceId,
@@ -96,42 +126,38 @@ export default async function handle(
const dubDiscount = await getDubDiscountForExternalUserId(userId);
const stripe = stripeInstance(oldAccount);
+ const baseSessionConfig = {
+ billing_address_collection: "required" as const,
+ success_url: `${process.env.NEXTAUTH_URL}/settings/billing?success=true`,
+ cancel_url: `${process.env.NEXTAUTH_URL}/settings/billing?cancel=true`,
+ line_items: [lineItem],
+ automatic_tax: {
+ enabled: true,
+ },
+ tax_id_collection: {
+ enabled: true,
+ },
+ mode: "subscription" as const,
+ client_reference_id: teamId,
+ ...(couponId && {
+ discounts: [{ coupon: couponId }],
+ }),
+ };
+
if (team.stripeId) {
// if the team already has a stripeId (i.e. is a customer) let's use as a customer
stripeSession = await stripe.checkout.sessions.create({
+ ...baseSessionConfig,
customer: team.stripeId,
customer_update: { name: "auto" },
- billing_address_collection: "required",
- success_url: `${process.env.NEXTAUTH_URL}/settings/billing?success=true`,
- cancel_url: `${process.env.NEXTAUTH_URL}/settings/billing?cancel=true`,
- line_items: [lineItem],
- automatic_tax: {
- enabled: true,
- },
- tax_id_collection: {
- enabled: true,
- },
- mode: "subscription",
- allow_promotion_codes: true,
- client_reference_id: teamId,
+ ...(!couponId && { allow_promotion_codes: true }),
});
} else {
// else initialize a new customer
stripeSession = await stripe.checkout.sessions.create({
+ ...baseSessionConfig,
customer_email: userEmail ?? undefined,
- billing_address_collection: "required",
- success_url: `${process.env.NEXTAUTH_URL}/settings/billing?success=true`,
- cancel_url: `${process.env.NEXTAUTH_URL}/settings/billing?cancel=true`,
- line_items: [lineItem],
- automatic_tax: {
- enabled: true,
- },
- tax_id_collection: {
- enabled: true,
- },
- mode: "subscription",
- client_reference_id: teamId,
- ...(dubDiscount ?? { allow_promotion_codes: true }),
+ ...(dubDiscount ?? (!couponId && { allow_promotion_codes: true })),
metadata: {
dubCustomerId: userId,
},
diff --git a/pages/branding.tsx b/pages/branding.tsx
index c8285af3..f29eaf1c 100644
--- a/pages/branding.tsx
+++ b/pages/branding.tsx
@@ -15,7 +15,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useBrand } from "@/lib/swr/use-brand";
import { cn, convertDataUrlToFile, uploadImage } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import AppLayout from "@/components/layouts/app";
import { NavMenu } from "@/components/navigation-menu";
import { Button } from "@/components/ui/button";
diff --git a/pages/datarooms/[id]/groups/index.tsx b/pages/datarooms/[id]/groups/index.tsx
index 4229d96f..ecc78a25 100644
--- a/pages/datarooms/[id]/groups/index.tsx
+++ b/pages/datarooms/[id]/groups/index.tsx
@@ -5,7 +5,7 @@ import { useState } from "react";
import { PlanEnum } from "@/ee/stripe/constants";
import { CircleHelpIcon, InfoIcon, UsersIcon } from "lucide-react";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { DataroomHeader } from "@/components/datarooms/dataroom-header";
import { DataroomNavigation } from "@/components/datarooms/dataroom-navigation";
import { AddGroupModal } from "@/components/datarooms/groups/add-group-modal";
@@ -37,12 +37,12 @@ export default function DataroomGroupPage() {
return <Button onClick={() => setModalOpen(true)}>Create group</Button>;
}
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="create_group_button"
>
<Button>Upgrade to create group</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
};
diff --git a/pages/datarooms/[id]/settings/index.tsx b/pages/datarooms/[id]/settings/index.tsx
index cb528da2..90be38a4 100644
--- a/pages/datarooms/[id]/settings/index.tsx
+++ b/pages/datarooms/[id]/settings/index.tsx
@@ -339,14 +339,14 @@ export default function Settings() {
</Button>
) : null}
{isNotBusiness ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={"Business"}
trigger={"feedback_question"}
>
<Button type="submit" loading={loading}>
{feedback ? "Update question" : "Create question"}
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
) : (
<Button type="submit" loading={loading}>
{feedback ? "Update question" : "Create question"}
diff --git a/pages/datarooms/index.tsx b/pages/datarooms/index.tsx
index 3efafba1..b9850c9f 100644
--- a/pages/datarooms/index.tsx
+++ b/pages/datarooms/index.tsx
@@ -14,7 +14,7 @@ import useLimits from "@/lib/swr/use-limits";
import { useTags } from "@/lib/swr/use-tags";
import { daysLeft } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { AddDataroomModal } from "@/components/datarooms/add-dataroom-modal";
import DataroomCard from "@/components/datarooms/dataroom-card";
import { DataroomTrialModal } from "@/components/datarooms/dataroom-trial-modal";
@@ -108,7 +108,7 @@ export default function DataroomsPage() {
</div>
<div className="flex items-center gap-x-1">
{isBusiness && !canCreateUnlimitedDatarooms ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
@@ -118,7 +118,7 @@ export default function DataroomsPage() {
>
<span>Upgrade to Add Data Room</span>
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
) : isTrial &&
datarooms &&
!isBusiness &&
@@ -142,7 +142,7 @@ export default function DataroomsPage() {
})()}
</span>
</div>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.DataRooms}
trigger="datarooms"
>
@@ -152,7 +152,7 @@ export default function DataroomsPage() {
>
<span>Upgrade to Add Data Room</span>
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
</div>
) : isBusiness || isDatarooms || isDataroomsPlus ? (
<AddDataroomModal>
diff --git a/pages/documents/[id]/index.tsx b/pages/documents/[id]/index.tsx
index 2b74ddc8..154c7133 100644
--- a/pages/documents/[id]/index.tsx
+++ b/pages/documents/[id]/index.tsx
@@ -10,7 +10,7 @@ import { PlanEnum } from "@/ee/stripe/constants";
import { useDocumentLinks } from "@/lib/swr/use-document";
import { useDocumentOverview } from "@/lib/swr/use-document-overview";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import { AnnotationSheet } from "@/components/documents/annotations/annotation-sheet";
import DocumentHeader from "@/components/documents/document-header";
import { DocumentPreviewButton } from "@/components/documents/document-preview-button";
@@ -98,14 +98,14 @@ export default function DocumentPage() {
const AddLinkButton = () => {
if (!limits?.canAddLinks) {
return (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={team?.isTrial ? PlanEnum.Business : PlanEnum.Pro}
trigger={"limit_add_link"}
>
<Button className="flex h-8 whitespace-nowrap text-xs lg:h-9 lg:text-sm">
Upgrade to Create Link
</Button>
- </UpgradePlanModal>
+ </UpgradePlanModalWithDiscount>
);
} else {
return (
diff --git a/pages/settings/general.tsx b/pages/settings/general.tsx
index 14f6b923..e900402b 100644
--- a/pages/settings/general.tsx
+++ b/pages/settings/general.tsx
@@ -10,7 +10,7 @@ import { usePlan } from "@/lib/swr/use-billing";
import { useTeamSettings } from "@/lib/swr/use-team-settings";
import { validateContent } from "@/lib/utils/sanitize-html";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import AppLayout from "@/components/layouts/app";
import DeleteTeam from "@/components/settings/delete-team";
import GlobalBlockListForm from "@/components/settings/global-block-list-form";
@@ -228,7 +228,7 @@ export default function General() {
</div>
{planModalOpen ? (
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={selectedPlan}
trigger={planModalTrigger}
open={planModalOpen}
diff --git a/pages/settings/presets/[id].tsx b/pages/settings/presets/[id].tsx
index 701a1fd2..772a311c 100644
--- a/pages/settings/presets/[id].tsx
+++ b/pages/settings/presets/[id].tsx
@@ -15,7 +15,7 @@ import useLimits from "@/lib/swr/use-limits";
import { WatermarkConfig } from "@/lib/types";
import { fetcher } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import AppLayout from "@/components/layouts/app";
import { DEFAULT_LINK_TYPE } from "@/components/links/link-sheet";
import AgreementSection from "@/components/links/link-sheet/agreement-section";
@@ -525,7 +525,7 @@ export default function EditPreset() {
</div>
</form>
</main>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={upgradePlan}
open={openUpgradeModal}
setOpen={setOpenUpgradeModal}
diff --git a/pages/settings/presets/index.tsx b/pages/settings/presets/index.tsx
index dd3ada03..fbb773f8 100644
--- a/pages/settings/presets/index.tsx
+++ b/pages/settings/presets/index.tsx
@@ -13,7 +13,7 @@ import useSWR from "swr";
import { usePlan } from "@/lib/swr/use-billing";
import { fetcher, formatExpirationTime } from "@/lib/utils";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import AppLayout from "@/components/layouts/app";
import { SettingsHeader } from "@/components/settings/settings-header";
import { Badge } from "@/components/ui/badge";
@@ -131,7 +131,7 @@ export default function Presets() {
)}
</div>
</main>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={PlanEnum.Business}
trigger="presets_page"
open={showUpgradeModal}
diff --git a/pages/settings/presets/new.tsx b/pages/settings/presets/new.tsx
index fd6d7bbe..37750c69 100644
--- a/pages/settings/presets/new.tsx
+++ b/pages/settings/presets/new.tsx
@@ -13,7 +13,7 @@ import { toast } from "sonner";
import { usePlan } from "@/lib/swr/use-billing";
import useLimits from "@/lib/swr/use-limits";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { UpgradePlanModalWithDiscount } from "@/components/billing/upgrade-plan-modal-with-discount";
import AppLayout from "@/components/layouts/app";
import {
DEFAULT_LINK_PROPS,
@@ -361,7 +361,7 @@ export default function NewPreset() {
</div>
</form>
</main>
- <UpgradePlanModal
+ <UpgradePlanModalWithDiscount
clickedPlan={upgradePlan}
open={openUpgradeModal}
setOpen={setOpenUpgradeModal}
diff --git a/pages/settings/upgrade-holiday-offer.tsx b/pages/settings/upgrade-holiday-offer.tsx
new file mode 100644
index 00000000..3533d329
--- /dev/null
+++ b/pages/settings/upgrade-holiday-offer.tsx
@@ -0,0 +1,769 @@
+import { useRouter } from "next/router";
+
+import { useEffect, useState } from "react";
+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, XIcon } from "lucide-react";
+import { toast } from "sonner";
+
+import { useAnalytics } from "@/lib/analytics";
+import { usePlan } from "@/lib/swr/use-billing";
+import { capitalize } from "@/lib/utils";
+
+import { Button } from "@/components/ui/button";
+import { Switch } from "@/components/ui/switch";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+
+// Calculate 30% discounted yearly price
+const getDiscountedYearlyPrice = (yearlyPrice: number) => {
+ return Math.round(yearlyPrice * 0.7); // Round to whole number
+};
+
+// Calculate savings: monthly*12 vs yearly*12*0.7
+const calculateSavings = (monthlyPrice: number, yearlyPrice: number) => {
+ const monthlyForYear = monthlyPrice * 12;
+ const yearlyWithDiscount = Math.round(yearlyPrice * 12 * 0.7);
+ return monthlyForYear - yearlyWithDiscount;
+};
+
+// 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">
+ {feature.isNotIncluded ? (
+ <XIcon className="h-6 w-5 flex-none text-gray-500" />
+ ) : (
+ <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}`}>
+ {feature.isNotIncluded ? (
+ <XIcon className="h-6 w-5 flex-none text-gray-500" />
+ ) : (
+ <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
+ )}
+ <span>{feature.text}</span>
+ </span>
+ );
+ }
+
+ return (
+ <div className={`gap-x-3 ${baseClasses}`}>
+ {feature.isNotIncluded ? (
+ <XIcon className="h-6 w-5 flex-none text-gray-500" />
+ ) : (
+ <CheckIcon className="h-6 w-5 flex-none text-[#fb7a00]" />
+ )}
+ <span>{feature.text}</span>
+ </div>
+ );
+};
+
+// Toggle component for Document Sharing vs Data Rooms
+const PlanTypeSelector = ({
+ value,
+ onChange,
+}: {
+ value: "documents" | "datarooms" | "business-datarooms";
+ onChange: (value: "documents" | "datarooms") => void;
+}) => {
+ const isDocuments = value === "documents";
+ const isDatarooms = value === "datarooms";
+
+ return (
+ <div className="mb-8 flex w-full max-w-md items-center justify-center rounded-lg border border-gray-200 p-1">
+ <button
+ className={`flex-1 rounded-md px-4 py-2 text-sm font-medium transition-colors ${
+ isDocuments
+ ? "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={() => onChange("documents")}
+ >
+ Document Sharing
+ </button>
+ <button
+ className={`flex-1 rounded-md px-4 py-2 text-sm font-medium transition-colors ${
+ isDatarooms
+ ? "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={() => onChange("datarooms")}
+ >
+ Data Rooms
+ </button>
+ </div>
+ );
+};
+
+export default function UpgradeHolidayOfferPage() {
+ const router = useRouter();
+ 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 analytics = useAnalytics();
+
+ // Determine initial view based on query params or default to datarooms
+ const getInitialView = () => {
+ if (router.query.view === "documents") return "documents";
+ if (router.query.view === "business-datarooms") return "business-datarooms";
+ return "datarooms";
+ };
+ const [planType, setPlanType] = useState<"documents" | "datarooms" | "business-datarooms">(getInitialView());
+
+ // Update planType when query param changes
+ useEffect(() => {
+ if (router.query.view === "documents") {
+ setPlanType("documents");
+ } else if (router.query.view === "business-datarooms") {
+ setPlanType("business-datarooms");
+ } else if (router.query.view === "datarooms" || !router.query.view) {
+ setPlanType("datarooms");
+ }
+ }, [router.query.view]);
+
+ // Document sharing plans (first 3)
+ const documentSharingPlans = [
+ PlanEnum.Pro,
+ PlanEnum.Business,
+ PlanEnum.DataRooms,
+ ];
+
+ 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>
+ <p className="mb-8 text-center text-sm text-gray-500 dark:text-gray-400">Additional 30% off on annual plans. Limited time offer. Ends Dec 31 2025</p>
+
+ <div className="mb-8 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 className="text-[#fb7a00]">(Save 50%)</span>
+ </span>
+ </div>
+
+ {/* Plan Type Selector */}
+ <div className="mb-8 flex justify-center">
+ <PlanTypeSelector
+ value={planType}
+ onChange={(value) => setPlanType(value)}
+ />
+ </div>
+
+ {/* Document Sharing Plans (3 in a row) */}
+ {planType === "documents" && (
+ <div className="grid grid-cols-1 gap-2 md:grid-cols-3 mb-8">
+ {documentSharingPlans.map((planOption) => {
+ const planFeatures = getPlanFeatures(planOption, { period });
+ const planData = PLANS.find((p) => p.name === planOption);
+ if (!planData) return null;
+
+ const monthlyPrice = planData.price.monthly.amount;
+ const yearlyPrice = planData.price.yearly.amount;
+ const discountedYearlyPrice = period === "yearly" ? getDiscountedYearlyPrice(yearlyPrice) : yearlyPrice;
+ const savings = period === "yearly" ? calculateSavings(monthlyPrice, yearlyPrice) : 0;
+
+ return (
+ <div
+ key={planOption}
+ className={`relative flex flex-col rounded-lg border ${
+ planOption === PlanEnum.Business || planOption === PlanEnum.DataRoomsPlus
+ ? "border-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "border-gray-900 dark:border-gray-200"
+ : "border-gray-400"
+ } 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">
+ {planOption}
+ </h3>
+ {period === "yearly" && savings > 0 && (
+ <span className="absolute right-2 top-2 rounded px-2 py-1 text-xs font-medium text-[#fb7a00] bg-[#fb7a00]/10">
+ Save €{savings}/year
+ </span>
+ )}
+ {period === "monthly" && (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-800 dark:bg-gray-200 dark:text-black"
+ : "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">
+ €
+ {period === "yearly" ? discountedYearlyPrice : monthlyPrice}
+ <span className="text-base font-normal dark:text-white/75">
+ /month
+ </span>
+ </div>
+ {period === "yearly" && (
+ <>
+ <div className="mb-2 flex items-center gap-2">
+ <span className="text-sm text-gray-500 line-through">
+ €{yearlyPrice}/month
+ </span>
+ <span className="rounded bg-[#fb7a00]/10 px-2 py-0.5 text-xs font-medium text-[#fb7a00]">
+ 30% OFF
+ </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"
+ >
+ {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]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "bg-gray-900 text-white hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200"
+ : "bg-gray-800 text-white hover:bg-gray-900 dark:hover:bg-gray-700/80"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ setSelectedPlan(planOption);
+ const priceId = period === "yearly"
+ ? PLANS.find((p) => p.name === planOption)!.price[period].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"]
+ : PLANS.find((p) => p.name === planOption)!.price[period].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"];
+
+ if (isCustomer && teamPlan !== "free") {
+ fetch(
+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ priceId,
+ upgradePlan: true,
+ applyYearlyDiscount: period === "yearly",
+ }),
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ } else {
+ fetch(
+ `/api/teams/${
+ teamInfo?.currentTeam?.id
+ }/billing/upgrade?priceId=${priceId}&applyYearlyDiscount=${period === "yearly"}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ 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>
+ )}
+
+ {/* Business + Data Rooms Plans (4 in a row) */}
+ {planType === "business-datarooms" && (
+ <div className="grid grid-cols-1 gap-2 md:grid-cols-4">
+ {[
+ PlanEnum.Business,
+ PlanEnum.DataRooms,
+ PlanEnum.DataRoomsPlus,
+ PlanEnum.DataRoomsPremium,
+ ].map((planOption) => {
+ const planFeatures = getPlanFeatures(planOption, { period });
+ const planData = PLANS.find((p) => p.name === planOption);
+ if (!planData) return null;
+
+ const monthlyPrice = planData.price.monthly.amount;
+ const yearlyPrice = planData.price.yearly.amount;
+ const discountedYearlyPrice = period === "yearly" ? getDiscountedYearlyPrice(yearlyPrice) : yearlyPrice;
+ const savings = period === "yearly" ? calculateSavings(monthlyPrice, yearlyPrice) : 0;
+
+ return (
+ <div
+ key={planOption}
+ className={`relative flex flex-col rounded-lg border ${
+ planOption === PlanEnum.Business
+ ? "border-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "border-gray-900 dark:border-gray-200"
+ : planOption === PlanEnum.DataRoomsPlus
+ ? "border-gray-800 dark:border-gray-300"
+ : "border-gray-400"
+ } 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">
+ {planOption}
+ </h3>
+ {period === "monthly" && (planOption === PlanEnum.Business ||
+ planOption === PlanEnum.DataRoomsPlus) && (
+ <span className="absolute -top-3 right-4 rounded px-2 py-1 text-xs text-white bg-[#fb7a00]">
+ {planOption === PlanEnum.Business
+ ? "Most popular"
+ : "Best offer"}
+ </span>
+ )}
+ {period === "yearly" && savings > 0 && (
+ <span className="absolute right-2 top-2 rounded px-2 py-1 text-xs font-medium text-[#fb7a00] bg-[#fb7a00]/10">
+ Save €{savings}/year
+ </span>
+ )}
+ </div>
+
+ <div className="mb-2 text-balance text-4xl font-medium tabular-nums text-foreground">
+ €
+ {period === "yearly" ? discountedYearlyPrice : monthlyPrice}
+ <span className="text-base font-normal dark:text-white/75">
+ /month
+ </span>
+ </div>
+ {period === "yearly" && (
+ <>
+ <div className="mb-2 flex items-center gap-2">
+ <span className="text-sm text-gray-500 line-through">
+ €{yearlyPrice}/month
+ </span>
+ <span className="rounded bg-[#fb7a00]/10 px-2 py-0.5 text-xs font-medium text-[#fb7a00]">
+ 30% OFF
+ </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"
+ >
+ {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]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "bg-gray-900 text-white hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200"
+ : "bg-gray-800 text-white hover:bg-gray-900 dark:hover:bg-gray-700/80"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ setSelectedPlan(planOption);
+ const priceId = PLANS.find((p) => p.name === planOption)!.price[
+ period
+ ].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"];
+
+ if (isCustomer && teamPlan !== "free") {
+ fetch(
+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ priceId,
+ upgradePlan: true,
+ applyYearlyDiscount: period === "yearly",
+ }),
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ } else {
+ fetch(
+ `/api/teams/${
+ teamInfo?.currentTeam?.id
+ }/billing/upgrade?priceId=${priceId}&applyYearlyDiscount=${period === "yearly"}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ 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>
+ )}
+
+ {/* Data Rooms Plans (3 in a row) */}
+ {planType === "datarooms" && (
+ <div className="grid grid-cols-1 gap-2 md:grid-cols-3">
+ {[
+ PlanEnum.DataRooms,
+ PlanEnum.DataRoomsPlus,
+ PlanEnum.DataRoomsPremium,
+ ].map((planOption) => {
+ const planFeatures = getPlanFeatures(planOption, { period });
+ const planData = PLANS.find((p) => p.name === planOption);
+ if (!planData) return null;
+
+ const monthlyPrice = planData.price.monthly.amount;
+ const yearlyPrice = planData.price.yearly.amount;
+ const discountedYearlyPrice = period === "yearly" ? getDiscountedYearlyPrice(yearlyPrice) : yearlyPrice;
+ const savings = period === "yearly" ? calculateSavings(monthlyPrice, yearlyPrice) : 0;
+
+ return (
+ <div
+ key={planOption}
+ className={`relative flex flex-col rounded-lg border ${
+ planOption === PlanEnum.Business
+ ? "border-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "border-gray-900 dark:border-gray-200"
+ : planOption === PlanEnum.DataRoomsPlus
+ ? "border-gray-800 dark:border-gray-300"
+ : "border-gray-400"
+ } 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">
+ {planOption}
+ </h3>
+ {period === "yearly" && savings > 0 && (
+ <span className="absolute right-2 top-2 rounded px-2 py-1 text-xs font-medium text-[#fb7a00] bg-[#fb7a00]/10">
+ Save €{savings}/year
+ </span>
+ )}
+ {period === "monthly" && (planOption === PlanEnum.Business ||
+ planOption === PlanEnum.DataRoomsPlus) && (
+ <span className="absolute -top-3 right-4 rounded px-2 py-1 text-xs text-white bg-[#fb7a00]">
+ {planOption === PlanEnum.Business
+ ? "Most popular"
+ : "Best offer"}
+ </span>
+ )}
+ </div>
+
+ <div className="mb-2 text-balance text-4xl font-medium tabular-nums text-foreground">
+ €
+ {period === "yearly" ? discountedYearlyPrice : monthlyPrice}
+ <span className="text-base font-normal dark:text-white/75">
+ /month
+ </span>
+ </div>
+ {period === "yearly" && (
+ <>
+ <div className="mb-2 flex items-center gap-2">
+ <span className="text-sm text-gray-500 line-through">
+ €{yearlyPrice}/month
+ </span>
+ <span className="rounded bg-[#fb7a00]/10 px-2 py-0.5 text-xs font-medium text-[#fb7a00]">
+ 30% OFF
+ </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"
+ >
+ {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 || planOption === PlanEnum.DataRoomsPlus
+ ? "bg-[#fb7a00]/90 text-white hover:bg-[#fb7a00]"
+ : planOption === PlanEnum.DataRoomsPremium
+ ? "bg-gray-900 text-white hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200"
+ : "bg-gray-800 text-white hover:bg-gray-900 dark:hover:bg-gray-700/80"
+ }`}
+ loading={selectedPlan === planOption}
+ disabled={selectedPlan !== null}
+ onClick={() => {
+ setSelectedPlan(planOption);
+ const priceId = PLANS.find((p) => p.name === planOption)!.price[
+ period
+ ].priceIds[
+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
+ ? "production"
+ : "test"
+ ][isOldAccount ? "old" : "new"];
+
+ if (isCustomer && teamPlan !== "free") {
+ fetch(
+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ priceId,
+ upgradePlan: true,
+ applyYearlyDiscount: period === "yearly",
+ }),
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setSelectedPlan(null);
+ });
+ } else {
+ fetch(
+ `/api/teams/${
+ teamInfo?.currentTeam?.id
+ }/billing/upgrade?priceId=${priceId}&applyYearlyDiscount=${period === "yearly"}`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ },
+ )
+ .then(async (res) => {
+ if (res.status === 429) {
+ toast.error(
+ "Rate limit exceeded. Please try again later.",
+ );
+ setSelectedPlan(null);
+ return;
+ }
+
+ 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 className="mt-8 flex flex-col items-center space-y-2">
+ <a
+ target="_blank"
+ className="text-sm text-muted-foreground underline-offset-4"
+ >
+ All plans include unlimited viewers and page by page document
+ analytics.
+ </a>
+ <a
+ href="https://cal.com/marcseitz/papermark"
+ target="_blank"
+ className="text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
+ >
+ Looking for Papermark Enterprise?
+ </a>
+ </div>
+ </div>
+ );
+}