The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
allow opening billing portal, update copy
Steven Teyc25488ca22ed
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsxindex ee894d9d99..71c3fedb63 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx@@ -391,7 +391,7 @@ const RecommendedForPayoutsWrapper = ({<span className="flex items-center gap-2 px-3 pb-1 pt-1.5 text-xs text-neutral-800"><MoneyBill2 className="size-3.5 shrink-0" /><span>- Recommended for Dub Partner payouts.{" "}+ Recommended for partner payouts.{" "}<Linkhref="https://dub.co/help/article/how-to-set-up-bank-account"target="_blank"diff --git a/apps/web/ui/workspaces/subscription-menu.tsx b/apps/web/ui/workspaces/subscription-menu.tsxindex 7bbee57944..c7172bb452 100644--- a/apps/web/ui/workspaces/subscription-menu.tsx+++ b/apps/web/ui/workspaces/subscription-menu.tsx@@ -40,43 +40,48 @@ export default function SubscriptionMenu() {const [isOpen, setIsOpen] = useState(false);const [clicked, setClicked] = useState(false);- const openBillingPortal = () => {+ const openBillingPortal = async () => {setIsOpen(false);setClicked(true);return fetch(`/api/workspaces/${workspaceId}/billing/manage`, {method: "POST",- }).then(async (res) => {- if (res.ok) {- const url = await res.json();- router.push(url);- } else {- const { error } = await res.json();- toast.error(error.message);+ })+ .then(async (res) => {+ if (res.ok) {+ const url = await res.json();+ router.push(url);+ } else {+ const { error } = await res.json();+ toast.error(error.message);+ }+ })+ .finally(() => {setClicked(false);- }- });+ });};- const cancelSubscription = () => {+ const cancelSubscription = async () => {setIsOpen(false);setClicked(true);return fetch(`/api/workspaces/${workspaceId}/billing/cancel`, {method: "POST",- }).then(async (res) => {- if (res.ok) {- // sleep for 2 seconds to make sure Stripe webhook was received, and then mutate- await new Promise((resolve) => setTimeout(resolve, 2000));- await mutate();- setClicked(false);- toast.success(- "Your subscription has been scheduled for cancellation at the end of the current period.",- );- } else {- const { error } = await res.json();- toast.error(error.message);+ })+ .then(async (res) => {+ if (res.ok) {+ // sleep for 2 seconds to make sure Stripe webhook was received, and then mutate+ await new Promise((resolve) => setTimeout(resolve, 2000));+ await mutate();+ toast.success(+ "Your subscription has been scheduled for cancellation at the end of the current period.",+ );+ } else {+ const { error } = await res.json();+ toast.error(error.message);+ }+ })+ .finally(() => {setClicked(false);- }- });+ });};// Check if canceling would lose partner access@@ -134,10 +139,6 @@ export default function SubscriptionMenu() {}};- if (plan === "enterprise") {- return null;- }-return (<><PlanChangeConfirmationModal />@@ -154,16 +155,18 @@ export default function SubscriptionMenu() {onSelect={() => openBillingPortal()}disabledTooltip={permissionsError}/>- <MenuItem- icon={SquareXmark}- label="Cancel subscription"- onSelect={handleCancelSubscription}- disabledTooltip={- subscriptionCanceledAt- ? "Your subscription has already been scheduled for cancellation."- : permissionsError- }- />+ {plan !== "enterprise" && (+ <MenuItem+ icon={SquareXmark}+ label="Cancel subscription"+ onSelect={handleCancelSubscription}+ disabledTooltip={+ subscriptionCanceledAt+ ? "Your subscription has already been scheduled for cancellation."+ : permissionsError+ }+ />+ )}</Command.List></Command>}@@ -171,7 +174,7 @@ export default function SubscriptionMenu() {><Buttontype="button"- className="h-9 px-2"+ className="size-9"variant="secondary"icon={<ThreeDots className="size-4 shrink-0" />}loading={clicked}