From 9d519fb5ec8c06c35f0967a0901940d934e1c882 Mon Sep 17 00:00:00 2001 From: Fringg Date: Sun, 22 Mar 2026 04:45:19 +0300 Subject: [PATCH] fix: show error state instead of blank page on purchase-options failure When the purchase-options API call failed (e.g. for email-registered users), the page rendered only the header with no content. Now shows an error message with retry button. Also adds a fallback for when the API returns no available tariffs or periods. --- src/pages/SubscriptionPurchase.tsx | 83 +++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/src/pages/SubscriptionPurchase.tsx b/src/pages/SubscriptionPurchase.tsx index 967637f..829a9fe 100644 --- a/src/pages/SubscriptionPurchase.tsx +++ b/src/pages/SubscriptionPurchase.tsx @@ -45,7 +45,12 @@ export default function SubscriptionPurchase() { const subscription = subscriptionResponse?.subscription ?? null; // Purchase options - const { data: purchaseOptions, isLoading: optionsLoading } = useQuery({ + const { + data: purchaseOptions, + isLoading: optionsLoading, + isError: optionsError, + refetch: refetchOptions, + } = useQuery({ queryKey: ['purchase-options'], queryFn: subscriptionApi.getPurchaseOptions, staleTime: 0, @@ -362,6 +367,58 @@ export default function SubscriptionPurchase() { ); } + if (optionsError || (!purchaseOptions && !optionsLoading)) { + return ( +
+
+ +

+ {t('subscription.extend')} +

+
+
+

+ {t('subscription.loadError', 'Не удалось загрузить варианты подписки')} +

+ +
+
+ ); + } + return (
{/* Header with back link */} @@ -1936,6 +1993,30 @@ export default function SubscriptionPurchase() { )}
)} + + {/* No options available fallback */} + {purchaseOptions && + !optionsLoading && + !(isTariffsMode && tariffs.length > 0) && + !(classicOptions && classicOptions.periods.length > 0) && ( +
+

+ {t('subscription.noOptionsAvailable', 'Нет доступных вариантов подписки')} +

+ +
+ )} ); }