From 83fbd0e44564a3b5f174f52549ff29b638701067 Mon Sep 17 00:00:00 2001 From: Fringg Date: Sat, 7 Mar 2026 00:01:47 +0300 Subject: [PATCH] fix: auto-select single sub-option and remove unused return_url field - Auto-select sub-option even when only 1 exists (backend needs suffix) - Remove return_url from public LandingPaymentMethod (backend doesn't send it) - Add else branch in auto-select for defensive null reset --- src/api/landings.ts | 1 - src/pages/QuickPurchase.tsx | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api/landings.ts b/src/api/landings.ts index a9739bf..28f6a05 100644 --- a/src/api/landings.ts +++ b/src/api/landings.ts @@ -42,7 +42,6 @@ export interface LandingPaymentMethod { min_amount_kopeks: number | null; max_amount_kopeks: number | null; currency: string | null; - return_url: string | null; sub_options: LandingPaymentMethodSubOption[] | null; } diff --git a/src/pages/QuickPurchase.tsx b/src/pages/QuickPurchase.tsx index dcff5af..b494be4 100644 --- a/src/pages/QuickPurchase.tsx +++ b/src/pages/QuickPurchase.tsx @@ -631,8 +631,10 @@ export default function QuickPurchase() { if (config.payment_methods.length > 0 && selectedMethod === null) { const firstMethod = config.payment_methods[0]; setSelectedMethod(firstMethod.method_id); - if (firstMethod.sub_options && firstMethod.sub_options.length > 1) { + if (firstMethod.sub_options && firstMethod.sub_options.length >= 1) { setSelectedSubOption(firstMethod.sub_options[0].id); + } else { + setSelectedSubOption(null); } } }, [config, allPeriods, visibleTariffs, selectedTariffId, selectedPeriodDays, selectedMethod]); @@ -899,8 +901,8 @@ export default function QuickPurchase() { } onSelect={() => { setSelectedMethod(method.method_id); - // Auto-select first sub-option when switching methods - if (method.sub_options && method.sub_options.length > 1) { + // Auto-select first sub-option (even for single — backend needs suffix) + if (method.sub_options && method.sub_options.length >= 1) { setSelectedSubOption(method.sub_options[0].id); } else { setSelectedSubOption(null);