Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add upgrade modal to domain modal if user is on free plan
Marc Seitz8c1a3f8a1bee
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsxindex cfc0af80..5f768611 100644--- a/components/billing/upgrade-plan-modal.tsx+++ b/components/billing/upgrade-plan-modal.tsx@@ -12,10 +12,14 @@ import { useTeam } from "@/context/team-context";export function UpgradePlanModal({clickedPlan,+ open,+ setOpen,children,}: {clickedPlan: "Starter" | "Pro";- children: React.ReactNode;+ open?: boolean;+ setOpen?: React.Dispatch<React.SetStateAction<boolean>>;+ children?: React.ReactNode;}) {const [plan, setPlan] = useState<"Starter" | "Pro">(clickedPlan);const [period, setPeriod] = useState<"monthly" | "yearly">("monthly");@@ -39,7 +43,7 @@ export function UpgradePlanModal({}, [plan]);return (- <Dialog>+ <Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>{children}</DialogTrigger><DialogContent className="text-foreground bg-background"><motion.divdiff --git a/components/domains/add-domain-modal.tsx b/components/domains/add-domain-modal.tsxindex 5142e691..5e19590c 100644--- a/components/domains/add-domain-modal.tsx+++ b/components/domains/add-domain-modal.tsx@@ -13,6 +13,8 @@ import { Label } from "@/components/ui/label";import { useTeam } from "@/context/team-context";import { useState } from "react";import { toast } from "sonner";+import { UpgradePlanModal } from "../billing/upgrade-plan-modal";+import { usePlan } from "@/lib/swr/use-billing";export function AddDomainModal({open,@@ -29,6 +31,7 @@ export function AddDomainModal({const [loading, setLoading] = useState<boolean>(false);const teamInfo = useTeam();+ const { plan } = usePlan();const handleSubmit = async (event: any) => {event.preventDefault();@@ -74,6 +77,21 @@ export function AddDomainModal({!onAddition && window.open("/settings/domains", "_blank");};+ // If the team is on a free plan, show the upgrade modal+ if (plan && plan.plan === "free") {+ if (children) {+ return (+ <UpgradePlanModal clickedPlan="Pro">+ <Button>Upgrade to Add Domain</Button>+ </UpgradePlanModal>+ );+ } else {+ return (+ <UpgradePlanModal clickedPlan="Pro" open={open} setOpen={setOpen} />+ );+ }+ }+return (<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>{children}</DialogTrigger>