Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
billing updates and fix on email name
Iuliia Shnaia84dde620671
diff --git a/components/billing/upgrade-plan-modal-old.tsx b/components/billing/upgrade-plan-modal-old.tsxnew file mode 100644index 00000000..438fe50c--- /dev/null+++ b/components/billing/upgrade-plan-modal-old.tsx@@ -0,0 +1,302 @@+import { useRouter } from "next/router";++import { useEffect, useMemo, useState } from "react";+import React from "react";++import { useTeam } from "@/context/team-context";+import { motion } from "framer-motion";+import { CheckIcon } from "lucide-react";++import { Button } from "@/components/ui/button";+import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";+import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";++import { useAnalytics } from "@/lib/analytics";+import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";+import { getStripe } from "@/lib/stripe/client";+import { PLANS } from "@/lib/stripe/utils";+import { usePlan } from "@/lib/swr/use-billing";+import { capitalize } from "@/lib/utils";++import { DataroomTrialModal } from "../datarooms/dataroom-trial-modal";+import { Badge } from "../ui/badge";++export function UpgradePlanModal({+ clickedPlan,+ trigger,+ open,+ setOpen,+ children,+}: {+ clickedPlan: "Data Rooms" | "Business" | "Pro";+ trigger?: string;+ open?: boolean;+ setOpen?: React.Dispatch<React.SetStateAction<boolean>>;+ children?: React.ReactNode;+}) {+ const router = useRouter();+ const [plan, setPlan] = useState<"Pro" | "Business" | "Data Rooms">(+ clickedPlan,+ );+ const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");+ const [clicked, setClicked] = useState<boolean>(false);+ const teamInfo = useTeam();+ const { plan: teamPlan, trial } = usePlan();+ const analytics = useAnalytics();++ const isTrial = !!trial;++ const features = useMemo(() => {+ if (plan === "Pro") {+ return [+ "2 users included",+ "Custom branding",+ "Folder organization",+ "Require email verification",+ "Papermark branding removed",+ "1-year analytics retention",+ ];+ }++ if (plan === "Business") {+ return [+ "3 users included",+ "1 dataroom",+ "Multi-file sharing",+ <span key="custom-domain">+ Custom domain <b>for documents</b>+ </span>,+ "Advanced link controls",+ "Allow/Block list",+ "Unlimited documents",+ "Unlimited subfolder levels",+ "Large file uploads",+ "48h priority support",+ ];+ }+ if (plan === "Data Rooms") {+ return [+ "3 users included",+ "Unlimited data rooms",+ <span key="custom-dataroom">+ Custom domain <b>for data rooms</b>+ </span>,++ "NDA agreements",+ "Dynamic watermark",+ "Granular user/group permisssions",+ "Advanced data rooms analytics",+ "24h priority support",+ "Custom onboarding",+ ];+ }++ return [+ "2 users",+ "Custom branding",+ "1-year analytics retention",+ "Folders",+ ];+ }, [plan]);++ // Track analytics event when modal is opened+ useEffect(() => {+ if (open) {+ analytics.capture("Upgrade Button Clicked", {+ trigger: trigger,+ teamId: teamInfo?.currentTeam?.id,+ });+ }+ }, [open, trigger]);++ // Track analytics event when child button is present+ const handleUpgradeClick = () => {+ analytics.capture("Upgrade Button Clicked", {+ trigger: trigger,+ teamId: teamInfo?.currentTeam?.id,+ });+ };++ // 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;++ return (+ <Dialog open={open} onOpenChange={setOpen}>+ <DialogTrigger asChild>{buttonChild}</DialogTrigger>+ <DialogContent className="bg-background text-foreground sm:max-w-[600px]">+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-border py-6 sm:px-10">+ <h2 className="text-2xl font-bold">+ Select the best plan for your business+ </h2>+ <Button+ variant="ghost"+ className="absolute right-4 top-4"+ onClick={() => setOpen?.(false)}+ >+ <X className="h-5 w-5" />+ </Button>+ </div>++ <div className="flex items-center justify-center space-x-2 py-4">+ <span className={cn("mr-2", period === "yearly" && "text-gray-400")}>+ Monthly+ </span>+ <Switch+ checked={period === "yearly"}+ onCheckedChange={(checked) =>+ setPeriod(checked ? "yearly" : "monthly")+ }+ className="h-5 w-10"+ />+ <span className={cn("ml-2", period === "monthly" && "text-gray-400")}>+ Annually{" "}+ <span className="ml-1 text-sm font-normal text-[#fb7a00]">+ (Save up to 25%)+ </span>+ </span>+ </div>++ <div className="space-y-4 px-6 py-4">+ <Tabs+ value={plan}+ onValueChange={(value) => setPlan(value as typeof plan)}+ >+ <TabsList className="grid w-full grid-cols-3">+ <TabsTrigger value="Pro">Pro</TabsTrigger>+ <TabsTrigger value="Business">Business</TabsTrigger>+ <TabsTrigger value="Data Rooms">Data Rooms</TabsTrigger>+ </TabsList>+ </Tabs>++ <div className="rounded-lg border border-border p-4">+ <div className="mb-4 flex items-center justify-between">+ <div className="flex items-center space-x-2">+ <h4 className="font-medium text-foreground">+ {plan} {capitalize(period)}+ </h4>+ <Badge+ variant="outline"+ className="text-sm font-normal normal-case"+ >+ {`€${PLANS.find((p) => p.name === plan)!.price[period].amount}/month`}+ {period === "yearly" && (+ <span className="ml-1 text-xs">(billed yearly)</span>+ )}+ </Badge>+ </div>+ <button+ onClick={() =>+ setPeriod(period === "monthly" ? "yearly" : "monthly")+ }+ className="text-xs text-muted-foreground underline underline-offset-4 transition-colors hover:text-gray-800 hover:dark:text-muted-foreground/80"+ >+ {period === "monthly"+ ? plan === "Business"+ ? "Want 43% off?"+ : plan === "Data Rooms"+ ? "Want 50% off?"+ : "Want 35% off?"+ : "Switch to monthly"}+ </button>+ </div>+ <ul className="space-y-2">+ {features.map((feature, i) => (+ <li+ key={i}+ className="flex items-center gap-x-3 text-sm text-muted-foreground"+ >+ <CheckIcon+ className="h-5 w-5 flex-none text-[#fb7a00]"+ aria-hidden="true"+ />+ <span>{feature}</span>+ </li>+ ))}+ </ul>+ </div>++ <Button+ className="w-full"+ loading={clicked}+ onClick={() => {+ setClicked(true);+ // @ts-ignore+ // prettier-ignore++ if (teamPlan !== "free") {+ fetch(+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,+ {+ method: "POST",+ },+ )+ .then(async (res) => {+ const url = await res.json();+ router.push(url);+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ } else {++ fetch(+ `/api/teams/${+ teamInfo?.currentTeam?.id+ }/billing/upgrade?priceId=${+ PLANS.find((p) => p.name === plan)!.price[period].priceIds[+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"+ ? "production"+ : "test"+ ]+ }`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ },+ )+ .then(async (res) => {+ const data = await res.json();+ const { id: sessionId } = data;+ const stripe = await getStripe();+ stripe?.redirectToCheckout({ sessionId });+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ }+ }}+ >{`Upgrade to ${plan} ${capitalize(period)}`}</Button>++ <div className="flex items-center justify-center space-x-2 text-center text-xs text-muted-foreground">+ {plan === "Business" && !isTrial ? (+ <DataroomTrialModal>+ <button+ className="underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"+ onClick={() => analytics.capture("Dataroom Trial Clicked")}+ >+ Looking for a trial?+ </button>+ </DataroomTrialModal>+ ) : (+ <a+ href="https://cal.com/marcseitz/papermark"+ target="_blank"+ className="underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"+ >+ Looking for Papermark Enterprise?+ </a>+ )}+ </div>+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsxindex 54367219..596cc42c 100644--- a/components/billing/upgrade-plan-modal.tsx+++ b/components/billing/upgrade-plan-modal.tsx@@ -8,8 +8,9 @@ import { motion } from "framer-motion";import { CheckIcon } from "lucide-react";import { Button } from "@/components/ui/button";+import { Checkbox } from "@/components/ui/checkbox";import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";-import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";+import { Switch } from "@/components/ui/switch";import { useAnalytics } from "@/lib/analytics";import { STAGGER_CHILD_VARIANTS } from "@/lib/constants";@@ -28,7 +29,7 @@ export function UpgradePlanModal({setOpen,children,}: {- clickedPlan: "Data Rooms" | "Business" | "Pro";+ clickedPlan: "Pro" | "Business" | "Data Rooms";trigger?: string;open?: boolean;setOpen?: React.Dispatch<React.SetStateAction<boolean>>;@@ -46,58 +47,63 @@ export function UpgradePlanModal({const isTrial = !!trial;- const features = useMemo(() => {- if (plan === "Pro") {- return [+ const planFeatures = useMemo(+ () => ({+ Pro: ["2 users included","Custom branding","Folder organization",+ "Unlimited links",+ "Unlimited documents","Require email verification",+ "More file types: pppt, docx, excel","Papermark branding removed","1-year analytics retention",- ];- }-- if (plan === "Business") {- return [+ ],+ Business: ["3 users included","1 dataroom","Multi-file sharing",- <span key="custom-domain">++ "Allow/Block list",+ <span key="custom-dataroom">Custom domain <b>for documents</b></span>,- "Advanced link controls",- "Allow/Block list",- "Unlimited documents",- "Unlimited subfolder levels",+ "Custom social media cards",+ "Unlimited folder and subfolder levels","Large file uploads",- "48h priority support",- ];- }- if (plan === "Data Rooms") {- return [+ "More file types: .dmg for AutoCad",+ "2-year analytics retention",+ ],+ "Data Rooms": ["3 users included","Unlimited data rooms",<span key="custom-dataroom">Custom domain <b>for data rooms</b></span>,-"NDA agreements",- "Dynamic watermark",+ "Dynamic Watermarking","Granular user/group permisssions",- "Advanced data rooms analytics",+ "Access Screen Customizatiion",+ "Advanced Data Rooms analytics","24h priority support",- "Custom onboarding",- ];- }+ ],+ }),+ [],+ );- return [- "2 users",- "Custom branding",- "1-year analytics retention",- "Folders",- ];- }, [plan]);+ const plansToShow = useMemo(() => {+ switch (clickedPlan) {+ case "Pro":+ return ["Pro", "Business"];+ case "Business":+ return ["Business", "Data Rooms"];+ case "Data Rooms":+ return ["Data Rooms"];+ default:+ return ["Pro", "Business"];+ }+ }, [clickedPlan]);// Track analytics event when modal is openeduseEffect(() => {@@ -127,196 +133,131 @@ export function UpgradePlanModal({return (<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>{buttonChild}</DialogTrigger>- <DialogContent className="bg-background text-foreground">- <motion.div- variants={{- show: {- transition: {- staggerChildren: 0.15,- },- },- }}- initial="hidden"- animate="show"- className="flex flex-col items-center justify-center space-y-3 border-b border-border py-8 sm:px-12"- >- <motion.div variants={STAGGER_CHILD_VARIANTS}>- <p className="text-2xl font-bold tracking-tighter text-foreground">- Papermark- </p>- </motion.div>- <motion.h3- className="text-lg font-medium"- variants={STAGGER_CHILD_VARIANTS}- >- Upgrade to {plan}- </motion.h3>- <motion.p- className="text-center text-sm text-muted-foreground"- variants={STAGGER_CHILD_VARIANTS}- >- Enjoy higher limits and extra features with our {plan} plan.- </motion.p>- </motion.div>+ <DialogContent+ className="max-h-[90vh] overflow-y-auto bg-gray-50 text-foreground"+ style={{ width: "90vw", maxWidth: "900px" }} // Adjusted maxWidth+ >+ <div className="flex items-center justify-center">+ <span className="mr-2 text-sm">Monthly</span>+ <Switch+ checked={period === "yearly"}+ onCheckedChange={() =>+ setPeriod(period === "monthly" ? "yearly" : "monthly")+ }+ />+ <span className="ml-2 text-sm">+ Annually <span className="text-orange-500">(Save up to 25%)</span>+ </span>+ </div>- <div className="bg-background pb-8 text-left sm:px-8">- <Tabs className="pb-4" defaultValue={plan}>- <TabsList className="grid w-full grid-cols-3">- <TabsTrigger value="Pro" onClick={() => setPlan("Pro")}>- Pro- </TabsTrigger>- <TabsTrigger value="Business" onClick={() => setPlan("Business")}>- Business- </TabsTrigger>- <TabsTrigger- value="Data Rooms"- onClick={() => setPlan("Data Rooms")}- >- Data Rooms- </TabsTrigger>- </TabsList>- </Tabs>- <motion.div- className="flex flex-col space-y-3"- variants={STAGGER_CHILD_VARIANTS}- initial="hidden"- animate="show"- >- <div className="mb-4">- <div className="mb-4 flex items-center justify-between">- <div className="flex items-center space-x-2">- <h4 className="font-medium text-foreground">- {plan} {capitalize(period)}- </h4>- <Badge- variant="outline"- className="text-sm font-normal normal-case"- >- {`€${- PLANS.find((p) => p.name === plan)!.price[period].amount- }/month`}{" "}- {period === "yearly" ? (- <span className="ml-1 text-xs">(billed yearly)</span>- ) : null}- </Badge>- </div>- <button- onClick={() => {- setPeriod(period === "monthly" ? "yearly" : "monthly");- }}- className="text-xs text-muted-foreground underline underline-offset-4 transition-colors hover:text-gray-800 hover:dark:text-muted-foreground/80"- >- {period === "monthly"- ? plan === "Business"- ? "Want 43% off?"- : plan === "Data Rooms"- ? "Want 50% off?"- : "Want 35% off?"- : "Switch to monthly"}- </button>+ <div className="isolate grid grid-cols-1 gap-4 overflow-hidden rounded-xl p-4 md:grid-cols-2">+ {plansToShow.map((planOption) => (+ <div+ key={planOption}+ className={`relative flex flex-col rounded-lg border ${+ planOption === "Business"+ ? "border-orange-500"+ : "border-gray-200"+ } bg-white p-6 shadow-sm`}+ >+ <div className="mb-4 border-b border-gray-200 pb-2">+ <h3 className="text-balance text-xl font-medium text-foreground text-gray-900">+ Papermark {planOption}+ </h3>+ {planOption === "Business" && (+ <span className="absolute right-2 top-2 rounded bg-orange-500 px-2 py-1 text-xs text-white">+ Most popular+ </span>+ )}</div>- <motion.div- variants={{- show: {- transition: {- staggerChildren: 0.08,- },- },- }}- initial="hidden"- animate="show"- className="flex flex-col space-y-2"- >- {features.map((feature, i) => (- <motion.div- key={i}- variants={STAGGER_CHILD_VARIANTS}- className="flex items-center gap-x-3 text-sm text-muted-foreground"- >- <CheckIcon- className="h-5 w-5 flex-none text-[#fb7a00]"- aria-hidden="true"- />- <span>{feature}</span>- </motion.div>- ))}- </motion.div>- </div>- <Button- loading={clicked}- onClick={() => {- setClicked(true);- // @ts-ignore- // prettier-ignore- if (teamPlan !== "free") {- fetch(- `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,- {- method: "POST",- },- )- .then(async (res) => {- const url = await res.json();- router.push(url);- })- .catch((err) => {- alert(err);- setClicked(false);- });- } else {+ <div className="mb-6 text-balance text-4xl font-medium text-foreground">+ €+ {PLANS.find((p) => p.name === planOption)!.price[period].amount}+ <span className="text-base font-normal">/month</span>+ </div>+ <ul className="mb-8 mt-4 space-y-3 text-sm leading-6 text-gray-600 dark:text-muted-foreground">+ {planFeatures[planOption as keyof typeof planFeatures].map(+ (feature, i) => (+ <li key={i} className="flex items-center text-sm">+ <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-orange-500" />+ <span>{feature}</span>+ </li>+ ),+ )}+ </ul>+ <div className="mt-auto">+ <Button+ variant={planOption === "Business" ? "default" : "outline"}+ className={`w-full py-2 text-sm ${+ planOption === "Business"+ ? "bg-orange-500 hover:bg-orange-600"+ : "bg-gray-800 text-white hover:bg-gray-900"+ }`}+ onClick={() => {+ setClicked(true);+ // @ts-ignore+ // prettier-ignore++ if (teamPlan !== "free") {+ fetch(+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,+ {+ method: "POST",+ },+ )+ .then(async (res) => {+ const url = await res.json();+ router.push(url);+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ } else {- fetch(- `/api/teams/${- teamInfo?.currentTeam?.id- }/billing/upgrade?priceId=${- PLANS.find((p) => p.name === plan)!.price[period].priceIds[- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"- ? "production"- : "test"- ]- }`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- },- },- )- .then(async (res) => {- const data = await res.json();- const { id: sessionId } = data;- const stripe = await getStripe();- stripe?.redirectToCheckout({ sessionId });- })- .catch((err) => {- alert(err);- setClicked(false);- });- }- }}- >{`Upgrade to ${plan} ${capitalize(period)}`}</Button>- <div className="flex items-center justify-center space-x-2">- {plan === "Business" && !isTrial ? (- <DataroomTrialModal>- <button- className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"- onClick={() => analytics.capture("Dataroom Trial Clicked")}- >- Looking for a trial?- </button>- </DataroomTrialModal>- ) : (- <a- href="https://cal.com/marcseitz/papermark"- target="_blank"- className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"- >- Looking for Papermark Enterprise?- </a>- )}+ fetch(+ `/api/teams/${+ teamInfo?.currentTeam?.id+ }/billing/upgrade?priceId=${+ PLANS.find((p) => p.name === planOption)!.price[period]+ .priceIds[+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"+ ? "production"+ : "test"+ ]+ }`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ },+ )+ .then(async (res) => {+ const data = await res.json();+ const { id: sessionId } = data;+ const stripe = await getStripe();+ stripe?.redirectToCheckout({ sessionId });+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ }+ }}+ >{`Upgrade to ${planOption} ${capitalize(period)}`}</Button>+ </div></div>- </motion.div>+ ))}+ </div>+ <div className="text-center">+ <a+ href="/settings/upgrade"+ className="text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"+ >+ See all plans+ </a></div></DialogContent></Dialog>diff --git a/components/emails/verification-link.tsx b/components/emails/verification-link.tsxindex 8c75a0e7..3bc4cda0 100644--- a/components/emails/verification-link.tsx+++ b/components/emails/verification-link.tsx@@ -20,7 +20,7 @@ const VerificationLinkEmail = ({return (<Html><Head />- <Preview>Your Papermark Login Link</Preview>+ <Preview>Login to your Papermark account with a link</Preview><Tailwind><Body className="mx-auto my-auto bg-white font-sans"><Container className="mx-auto my-10 max-w-[500px] rounded border border-solid border-gray-200 px-10 py-5">@@ -32,7 +32,7 @@ const VerificationLinkEmail = ({</Text><Text className="text-sm leading-6 text-black">- Welcome to Papermark!+ Your Papermark Login Link</Text><Text className="text-sm leading-6 text-black">Please click the magic link below to sign in to your account.diff --git a/lib/stripe/utils.ts b/lib/stripe/utils.tsindex e6ea2e83..df3afa6d 100644--- a/lib/stripe/utils.ts+++ b/lib/stripe/utils.ts@@ -58,7 +58,7 @@ export const PLANS = [},},yearly: {- amount: 25,+ amount: 29,priceIds: {test: "price_1P3JlWFJyGSZ96lhddEsPKGg",production: "price_1P6VTgFJyGSZ96lhshdgZ1it",@@ -66,6 +66,25 @@ export const PLANS = [},},},+ {+ name: "Pro with Custom Domain",+ price: {+ monthly: {+ amount: 59,+ priceIds: {+ test: "price_1Q05u4FJyGSZ96lhDFRzhFgj",+ production: "price_prod_id_pro_custom_domain_monthly",+ },+ },+ yearly: {+ amount: 49,+ priceIds: {+ test: "price_1Q16E9FJyGSZ96lhhepSttFn",+ production: "price_prod_id_pro_custom_domain_yearly",+ },+ },+ },+ },{name: "Business",slug: "business",@@ -73,12 +92,12 @@ export const PLANS = [monthly: {amount: 79,priceIds: {- test: "price_1OuYgCFJyGSZ96lhF2gFs7Rs",+ test: "price_1Q16AsFJyGSZ96lhkjNBhOJd",production: "price_1OuYeIFJyGSZ96lhwH58Y1kU",},},yearly: {- amount: 45,+ amount: 59,priceIds: {test: "price_1PTn5iFJyGSZ96lhMbSVkntM",production: "price_1PThmeFJyGSZ96lh1cY3Klrq",@@ -86,12 +105,31 @@ export const PLANS = [},},},+ {+ name: "Business with Custom Domain",+ price: {+ monthly: {+ amount: 109,+ priceIds: {+ test: "price_1Q16CLFJyGSZ96lhYxMLSJm0",+ production: "price_prod_id_pro_custom_domain_monthly",+ },+ },+ yearly: {+ amount: 79,+ priceIds: {+ test: "price_1Q16DHFJyGSZ96lhDxFnXdNh",+ production: "price_prod_id_pro_custom_domain_yearly",+ },+ },+ },+ },{name: "Data Rooms",slug: "datarooms",price: {monthly: {- amount: 199,+ amount: 149,priceIds: {test: "price_1PAtTfFJyGSZ96lhbi4XZU2d",production: "price_1PAtQOFJyGSZ96lhJNZO2LHx",diff --git a/pages/settings/upgrade.tsx b/pages/settings/upgrade.tsxnew file mode 100644index 00000000..691a26b3--- /dev/null+++ b/pages/settings/upgrade.tsx@@ -0,0 +1,206 @@+import { useRouter } from "next/router";++import { useEffect, useMemo, useState } from "react";+import React from "react";++import { useTeam } from "@/context/team-context";+import { CheckIcon } from "lucide-react";++import { Button } from "@/components/ui/button";+import { Switch } from "@/components/ui/switch";++import { useAnalytics } from "@/lib/analytics";+import { getStripe } from "@/lib/stripe/client";+import { PLANS } from "@/lib/stripe/utils";+import { usePlan } from "@/lib/swr/use-billing";+import { capitalize } from "@/lib/utils";++export default function UpgradePage() {+ const router = useRouter();+ const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");+ const [clicked, setClicked] = useState<boolean>(false);+ const teamInfo = useTeam();+ const { plan: teamPlan, trial } = usePlan();+ const analytics = useAnalytics();++ const planFeatures = useMemo(+ () => ({+ Pro: [+ "2 users included",+ "Custom branding",+ "Folder organization",+ "Unlimited links",+ "Unlimited documents",+ "Require email verification",+ "More file types: pppt, docx, excel",+ "Papermark branding removed",+ "1-year analytics retention",+ ],+ Business: [+ "3 users included",+ "1 dataroom",+ "Multi-file sharing",++ "Allow/Block list",+ <span key="custom-dataroom">+ Custom domain <b>for documents</b>+ </span>,+ "Custom social media cards",+ "Unlimited folder and subfolder levels",+ "Large file uploads",+ "More file types: .dmg for AutoCad",+ "2-year analytics retention",+ ],+ "Data Rooms": [+ "3 users included",+ "Unlimited data rooms",+ <span key="custom-dataroom">+ Custom domain <b>for data rooms</b>+ </span>,+ "NDA agreements",+ "Dynamic Watermarking",+ "Granular user/group permisssions",+ "Access Screen Customizatiion",+ "Advanced Data Rooms analytics",+ "24h priority support",+ ],+ }),+ [],+ );++ const plansToShow = ["Pro", "Business", "Data Rooms"];++ // Remove the useEffect hook that was causing the error++ return (+ <div className="min-h-screen bg-gray-50 p-8">+ <h1 className="mb-8 text-center text-3xl font-bold">+ Select best plan for your business+ </h1>++ <div className="mb-8 flex items-center justify-center">+ <span className="mr-2 text-sm">Monthly</span>+ <Switch+ checked={period === "yearly"}+ onCheckedChange={() =>+ setPeriod(period === "monthly" ? "yearly" : "monthly")+ }+ />+ <span className="ml-2 text-sm">+ Annually <span className="text-orange-500">(Save up to 25%)</span>+ </span>+ </div>++ <div className="grid grid-cols-1 gap-8 md:grid-cols-3">+ {plansToShow.map((planOption) => (+ <div+ key={planOption}+ className={`relative flex flex-col rounded-lg border ${+ planOption === "Business"+ ? "border-orange-500"+ : "border-gray-200"+ } bg-white p-6 shadow-sm`}+ >+ <div className="mb-4 border-b border-gray-200 pb-2">+ <h3 className="text-balance text-xl font-medium text-foreground text-gray-900">+ Papermark {planOption}+ </h3>+ {planOption === "Business" && (+ <span className="absolute right-2 top-2 rounded bg-orange-500 px-2 py-1 text-xs text-white">+ Most popular+ </span>+ )}+ </div>++ <div className="mb-6 text-balance text-4xl font-medium text-foreground">+ €{PLANS.find((p) => p.name === planOption)!.price[period].amount}+ <span className="text-base font-normal">/month</span>+ </div>+ <ul className="mb-8 mt-4 space-y-3 text-sm leading-6 text-gray-600 dark:text-muted-foreground">+ {planFeatures[planOption as keyof typeof planFeatures].map(+ (feature, i) => (+ <li key={i} className="flex items-center text-sm">+ <CheckIcon className="mr-3 h-5 w-5 flex-shrink-0 text-orange-500" />+ <span>{feature}</span>+ </li>+ ),+ )}+ </ul>+ <div className="mt-auto">+ <Button+ variant={planOption === "Business" ? "default" : "outline"}+ className={`w-full py-2 text-sm ${+ planOption === "Business"+ ? "bg-orange-500 hover:bg-orange-600"+ : "bg-gray-800 text-white hover:bg-gray-900"+ }`}+ onClick={() => {+ setClicked(true);+ // @ts-ignore+ // prettier-ignore++ if (teamPlan !== "free") {+ fetch(+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,+ {+ method: "POST",+ },+ )+ .then(async (res) => {+ const url = await res.json();+ router.push(url);+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ } else {++ fetch(+ `/api/teams/${+ teamInfo?.currentTeam?.id+ }/billing/upgrade?priceId=${+ PLANS.find((p) => p.name === planOption)!.price[period]+ .priceIds[+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"+ ? "production"+ : "test"+ ]+ }`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ },+ )+ .then(async (res) => {+ const data = await res.json();+ const { id: sessionId } = data;+ const stripe = await getStripe();+ stripe?.redirectToCheckout({ sessionId });+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ }+ }}+ >{`Upgrade to ${planOption} ${capitalize(period)}`}</Button>+ </div>+ </div>+ ))}+ </div>++ <div className="mt-8 text-center">+ <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>+ );+}