Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(billing): show error state instead of upsell card on query failure

Richie McIlroy89b0d4f4355e
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/BillingSummaryCard.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/BillingSummaryCard.tsx
index eb5a3bb46..4779087e9 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/BillingSummaryCard.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/BillingSummaryCard.tsx
@@ -19,16 +19,19 @@ export function BillingSummaryCard() {
const [billingLoading, setBillingLoading] = useState(false);
const organizationId = activeOrganization?.organization.id;
- const { data: subscription, isLoading } =
- useQuery<SubscriptionDetails | null>({
- queryKey: ["subscription-details", organizationId],
- queryFn: () => {
- if (!organizationId) return null;
- return getSubscriptionDetails(organizationId);
- },
- enabled: !!organizationId,
- staleTime: 60 * 1000,
- });
+ const {
+ data: subscription,
+ isLoading,
+ isError,
+ } = useQuery<SubscriptionDetails | null>({
+ queryKey: ["subscription-details", organizationId],
+ queryFn: () => {
+ if (!organizationId) return null;
+ return getSubscriptionDetails(organizationId);
+ },
+ enabled: !!organizationId,
+ staleTime: 60 * 1000,
+ });
const handleManageBilling = useCallback(async () => {
setBillingLoading(true);
@@ -54,6 +57,16 @@ export function BillingSummaryCard() {
);
}
+ if (isError) {
+ return (
+ <Card>
+ <p className="text-sm text-gray-10">
+ Unable to load billing details. Please try again later.
+ </p>
+ </Card>
+ );
+ }
+
if (!subscription) {
return (
<Card className="flex flex-wrap gap-6 justify-between items-center w-full">