diff --git a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx
index ddb7e525e..0fe3c2a07 100644
--- a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx
+++ b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx
@@ -12,6 +12,8 @@ import {
import Link from "next/link";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
+import { toast } from "sonner";
+import { DialogAction } from "@/components/shared/dialog-action";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
@@ -196,7 +198,7 @@ export const ShowBilling = () => {
{useNewPricing &&
data?.currentPlan === "legacy" &&
data?.subscriptions?.length > 0 && (
-
+
Upgrade your plan
You’re on the legacy plan. Switch to Hobby or Startup
@@ -311,34 +313,73 @@ export const ShowBilling = () => {
? `$${calculatePriceHobby(upgradeServerQty, updateFormAnnual).toFixed(2)} per ${updateFormAnnual ? "year" : "month"}`
: `$${calculatePriceStartup(upgradeServerQty, updateFormAnnual).toFixed(2)} per ${updateFormAnnual ? "year" : "month"}`}
-
}
+ type="default"
onClick={async () => {
if (!upgradeTier) return;
- await upgradeSubscription({
- tier: upgradeTier,
- serverQuantity: upgradeServerQty,
- isAnnual: updateFormAnnual,
- });
- await utils.stripe.getProducts.invalidate();
- await utils.user.get.invalidate();
- setUpgradeTier(null);
+ try {
+ await upgradeSubscription({
+ tier: upgradeTier,
+ serverQuantity: upgradeServerQty,
+ isAnnual: updateFormAnnual,
+ });
+ await utils.stripe.getProducts.invalidate();
+ await utils.user.get.invalidate();
+ setUpgradeTier(null);
+ toast.success("Plan upgraded successfully");
+ } catch {
+ toast.error("Error upgrading plan");
+ }
}}
>
- {isUpgrading ? (
- <>
-
- Upgrading…
- >
- ) : (
- "Upgrade plan"
- )}
-
+
+
)}
@@ -348,7 +389,7 @@ export const ShowBilling = () => {
(data?.currentPlan === "hobby" ||
data?.currentPlan === "startup") &&
data?.subscriptions?.length > 0 && (
-
+
Change plan or number of servers
@@ -366,8 +407,7 @@ export const ShowBilling = () => {
<>
{" · "}
- $
- {data.currentPriceAmount.toFixed(2)}/
+ ${data.currentPriceAmount.toFixed(2)}/
{data?.isAnnualCurrent ? "yr" : "mo"}
>
@@ -487,35 +527,92 @@ export const ShowBilling = () => {
? `$${calculatePriceHobby(upgradeServerQty, updateFormAnnual).toFixed(2)} per ${updateFormAnnual ? "year" : "month"}`
: `$${calculatePriceStartup(upgradeServerQty, updateFormAnnual).toFixed(2)} per ${updateFormAnnual ? "year" : "month"}`}
-
}
+ type="default"
onClick={async () => {
if (!upgradeTier) return;
- await upgradeSubscription({
- tier: upgradeTier,
- serverQuantity: upgradeServerQty,
- isAnnual: updateFormAnnual,
- });
- await utils.stripe.getProducts.invalidate();
- await utils.user.get.invalidate();
- setUpgradeTier(null);
- // window.location.reload();
+ try {
+ await upgradeSubscription({
+ tier: upgradeTier,
+ serverQuantity: upgradeServerQty,
+ isAnnual: updateFormAnnual,
+ });
+ await utils.stripe.getProducts.invalidate();
+
+ // add delay of 3 seconds
+ await new Promise((resolve) =>
+ setTimeout(resolve, 3000),
+ );
+ await utils.user.get.invalidate();
+ setUpgradeTier(null);
+ toast.success(
+ "Subscription updated successfully",
+ );
+ } catch {
+ toast.error("Error updating subscription");
+ }
}}
>
- {isUpgrading ? (
- <>
-
- Updating…
- >
- ) : (
- "Update subscription"
- )}
-
+
+
)}