diff --git a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx index c740f8211..cbc363dcd 100644 --- a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx +++ b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx @@ -2,6 +2,7 @@ import { loadStripe } from "@stripe/stripe-js"; import clsx from "clsx"; import { AlertTriangle, + Bell, CheckIcon, CreditCard, FileText, @@ -25,7 +26,17 @@ import { CardTitle, } from "@/components/ui/card"; import { NumberInput } from "@/components/ui/input"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Label } from "@/components/ui/label"; import { Progress } from "@/components/ui/progress"; +import { Switch } from "@/components/ui/switch"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; @@ -90,6 +101,8 @@ export const ShowBilling = () => { api.stripe.createCustomerPortalSession.useMutation(); const { mutateAsync: upgradeSubscription, isPending: isUpgrading } = api.stripe.upgradeSubscription.useMutation(); + const { mutateAsync: updateInvoiceNotifications } = + api.stripe.updateInvoiceNotifications.useMutation(); const utils = api.useUtils(); const [hobbyServerQuantity, setHobbyServerQuantity] = useState(1); @@ -151,14 +164,68 @@ export const ShowBilling = () => {
- - - - Billing - - - Manage your subscription and invoices - + +
+ + + Billing + + + Manage your subscription and invoices + +
+ {(admin?.user.stripeSubscriptionId || isEnterpriseCloud) && ( + + + + + + + Notification Settings + + Configure your billing email notifications. + + +
+
+ +

+ Receive email notifications for payments and failed + charges. +

+
+ { + await updateInvoiceNotifications({ + enabled: checked, + }) + .then(() => { + utils.user.get.invalidate(); + toast.success( + checked + ? "Invoice notifications enabled" + : "Invoice notifications disabled", + ); + }) + .catch(() => { + toast.error( + "Failed to update invoice notifications", + ); + }); + }} + /> +
+
+
+ )}