From 71a21e185ecef76e4050b11d74470beb3eb06fe2 Mon Sep 17 00:00:00 2001 From: MananTank Date: Tue, 29 Oct 2024 18:12:20 +0000 Subject: [PATCH] Fix page crash caused by BillingAlert component (#5220) Fixes: DASH-356 --- .../settings/Account/Billing/alerts/Alert.tsx | 39 +++-- .../Billing/alerts/BillingAlerts.stories.tsx | 163 +++++++++--------- .../alerts/RecurringPaymentFailureAlert.tsx | 5 +- 3 files changed, 106 insertions(+), 101 deletions(-) diff --git a/apps/dashboard/src/components/settings/Account/Billing/alerts/Alert.tsx b/apps/dashboard/src/components/settings/Account/Billing/alerts/Alert.tsx index 328fe510c76..41605929b5c 100644 --- a/apps/dashboard/src/components/settings/Account/Billing/alerts/Alert.tsx +++ b/apps/dashboard/src/components/settings/Account/Billing/alerts/Alert.tsx @@ -1,5 +1,4 @@ "use client"; - import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { TrackedLinkTW } from "@/components/ui/tracked-link"; @@ -12,14 +11,15 @@ import { useAccountUsage, } from "@3rdweb-sdk/react/hooks/useApi"; import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser"; -import { useDisclosure } from "@chakra-ui/react"; +import * as Sentry from "@sentry/nextjs"; import { OnboardingModal } from "components/onboarding/Modal"; import { format } from "date-fns"; import { useTrack } from "hooks/analytics/useTrack"; import { useLocalStorage } from "hooks/useLocalStorage"; import { ExternalLinkIcon, XIcon } from "lucide-react"; import { usePathname } from "next/navigation"; -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; +import { ErrorBoundary, type FallbackProps } from "react-error-boundary"; import { LazyOnboardingBilling } from "../../../../onboarding/LazyOnboardingBilling"; import { ManageBillingButton } from "../ManageButton"; import { RecurringPaymentFailureAlert } from "./RecurringPaymentFailureAlert"; @@ -301,7 +301,9 @@ export function BillingAlertsUI(props: { } return ( -
{alerts}
+ +
{alerts}
+
); } @@ -331,16 +333,11 @@ const AddPaymentNotification: React.FC = ({ // TODO: We should find a way to move this deeper into the // TODO: ManageBillingButton component and set an optional field to override const [paymentMethodSaving, setPaymentMethodSaving] = useState(false); - - const { - onOpen: onPaymentMethodOpen, - onClose: onPaymentMethodClose, - isOpen: isPaymentMethodOpen, - } = useDisclosure(); + const [isPaymentMethodOpen, setIsPaymentMethodOpen] = useState(false); const handlePaymentAdded = () => { setPaymentMethodSaving(true); - onPaymentMethodClose(); + setIsPaymentMethodOpen(false); }; const isBilling = ctaHref === "/dashboard/settings/billing"; @@ -353,7 +350,7 @@ const AddPaymentNotification: React.FC = ({ setIsPaymentMethodOpen(false)} /> @@ -361,13 +358,13 @@ const AddPaymentNotification: React.FC = ({ {description} {showCTAs && ( -
+
{isBilling ? ( setIsPaymentMethodOpen(true)} /> ) : (
)} -
+