Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Improve Loading Performance and UI in dark mode (#824)
ShreyasLakhani6bd05aa2677a
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsxindex a5159f6a..c58dc82e 100644--- a/components/billing/upgrade-plan-modal.tsx+++ b/components/billing/upgrade-plan-modal.tsx@@ -41,7 +41,7 @@ export function UpgradePlanModal({clickedPlan,);const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");- const [clicked, setClicked] = useState<boolean>(false);+ const [selectedPlan, setSelectedPlan] = useState<string | null>(null); // Track the clicked planconst teamInfo = useTeam();const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();const analytics = useAnalytics();@@ -59,7 +59,6 @@ export function UpgradePlanModal({"Custom branding","Folder organization","Require email verification",- "Clickable links inside documents","More file types: pppt, docx, excel","Papermark branding removed","1-year analytics retention",@@ -94,7 +93,7 @@ export function UpgradePlanModal({"Advanced data rooms analytics","NDA agreements","Dynamic Watermark",- "Granular user/group permisssions",+ "Granular user/group permissions","Invite users directly from Papermark","Audit log","24h priority support",@@ -134,7 +133,6 @@ export function UpgradePlanModal({}}, [open, trigger]);- // Track analytics event when child button is presentconst handleUpgradeClick = () => {analytics.capture("Upgrade Button Clicked", {trigger: trigger,@@ -216,7 +214,7 @@ export function UpgradePlanModal({}</p>- <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-white/75">+ <ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-muted-foreground">{planFeatures[planOption as keyof typeof planFeatures].features.map((feature, i) => (@@ -232,12 +230,13 @@ export function UpgradePlanModal({variant={planOption === "Business" ? "default" : "outline"}className={`w-full py-2 text-sm ${planOption === "Business"- ? "bg-[#fb7a00] hover:bg-[#fb7a00]"+ ? "bg-[#fb7a00] text-white hover:bg-[#fb7a00]": "bg-gray-800 text-white hover:bg-gray-900 hover:text-white"}`}- loading={clicked}+ loading={selectedPlan === planOption} // Show loading only for the clicked plan+ disabled={selectedPlan !== null}onClick={() => {- setClicked(true);+ setSelectedPlan(planOption); // Set the clicked planif (isCustomer && teamPlan !== "free") {fetch(`/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,@@ -251,21 +250,11 @@ export function UpgradePlanModal({}).catch((err) => {alert(err);- setClicked(false);+ setSelectedPlan(null); // Reset loading state on error});} else {fetch(- `/api/teams/${- teamInfo?.currentTeam?.id- }/billing/upgrade?priceId=${- PLANS.find((p) => p.name === planOption)!.price[- period- ].priceIds[- process.env.NEXT_PUBLIC_VERCEL_ENV === "production"- ? "production"- : "test"- ][isOldAccount ? "old" : "new"]- }`,+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/upgrade?priceId=${PLANS.find((p) => p.name === planOption)!.price[period].priceIds[process.env.NEXT_PUBLIC_VERCEL_ENV === "production" ? "production" : "test"][isOldAccount ? "old" : "new"]}`,{method: "POST",headers: {@@ -281,12 +270,12 @@ export function UpgradePlanModal({}).catch((err) => {alert(err);- setClicked(false);+ setSelectedPlan(null); // Reset loading state on error});}}}>- {clicked+ {selectedPlan === planOption? "Redirecting to Stripe...": `Upgrade to ${planOption} ${capitalize(period)}`}</Button>diff --git a/pages/settings/upgrade.tsx b/pages/settings/upgrade.tsxindex 0b82dbd1..137ab29c 100644--- a/pages/settings/upgrade.tsx+++ b/pages/settings/upgrade.tsx@@ -1,6 +1,6 @@import { useRouter } from "next/router";-import { useEffect, useMemo, useState } from "react";+import { useMemo, useState } from "react";import React from "react";import { useTeam } from "@/context/team-context";@@ -18,7 +18,7 @@ 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 [selectedPlan, setSelectedPlan] = useState<string | null>(null); // Track the clicked planconst teamInfo = useTeam();const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();const analytics = useAnalytics();@@ -68,7 +68,7 @@ export default function UpgradePage() {"Advanced data rooms analytics","NDA agreements","Dynamic Watermark",- "Granular user/group permisssions",+ "Granular user/group permissions","Invite users directly from Papermark","Audit log","24h priority support",@@ -78,9 +78,8 @@ export default function UpgradePage() {}),[],);- const plansToShow = ["Pro", "Business", "Data Rooms"];- // Remove the useEffect hook that was causing the error+ const plansToShow = ["Pro", "Business", "Data Rooms"];return (<div className="min-h-screen bg-gray-50 p-8 dark:bg-gray-900">@@ -133,7 +132,7 @@ export default function UpgradePage() {}</p>- <ul className="mb-4 mt-4 space-y-3 text-sm leading-6 text-gray-600 dark:text-white/75">+ <ul className="mb-4 mt-4 space-y-3 text-sm leading-6 text-gray-600 dark:text-muted-foreground">{planFeatures[planOption as keyof typeof planFeatures].features.map((feature, i) => (@@ -148,12 +147,13 @@ export default function UpgradePage() {variant={planOption === "Business" ? "default" : "default"}className={`w-full py-2 text-sm ${planOption === "Business"- ? "bg-[#fb7a00] hover:bg-[#fb7a00]/80"+ ? "bg-[#fb7a00] text-white hover:bg-[#fb7a00]/80": "bg-gray-800 text-white hover:bg-gray-900"}`}- loading={clicked}+ loading={selectedPlan === planOption} // Show loading only for the clicked plan+ disabled={selectedPlan !== null}onClick={() => {- setClicked(true);+ setSelectedPlan(planOption); // Set the clicked planif (isCustomer && teamPlan !== "free") {fetch(`/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,@@ -167,7 +167,7 @@ export default function UpgradePage() {}).catch((err) => {alert(err);- setClicked(false);+ setSelectedPlan(null); // Reset loading state on error});} else {fetch(@@ -196,12 +196,12 @@ export default function UpgradePage() {}).catch((err) => {alert(err);- setClicked(false);+ setSelectedPlan(null); // Reset loading state on error});}}}>- {clicked+ {selectedPlan === planOption? "Redirecting to Stripe...": `Upgrade to ${planOption} ${capitalize(period)}`}</Button>