mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix(cabinet): show trial offer in multi-tariff mode
Two cabinet routes never showed TrialOfferCard for users without any subscription when MULTI_TARIFF was enabled: 1. Dashboard (/) hasNoSubscription was derived from subscriptionResponse, but the /cabinet/subscription query is disabled in multi-tariff mode (`enabled: !isMultiTariff`). subscriptionResponse stayed undefined forever, so `has_subscription === false` was never true and the trial card never rendered. Fix: branch on isMultiTariff — use multiSubData.subscriptions.length when in multi-tariff, keep the single-tariff path unchanged. 2. /subscriptions list When the array came back empty the page rendered EmptyState directly, bypassing trial eligibility entirely. Users who navigated to 'Подписки' from the menu before opening the dashboard saw the empty placeholder and nothing about the trial. Fix: fetch trial-info on empty state, render TrialOfferCard if trialInfo.is_available, fall back to EmptyState otherwise. Also wired the activate mutation locally (mirrors Dashboard) so the button works without bouncing through the home screen first. Single-tariff behavior is unchanged. After the fix both entry points agree: if you have no subscriptions and trial is available, you see the offer regardless of which page you opened first.
This commit is contained in:
@@ -195,7 +195,12 @@ export default function Dashboard() {
|
||||
refreshTrafficMutation.mutate();
|
||||
}, [subscription, refreshTrafficMutation]);
|
||||
|
||||
const hasNoSubscription = subscriptionResponse?.has_subscription === false && !subLoading;
|
||||
// В multi-tariff /cabinet/subscription отключён, поэтому subscriptionResponse=undefined.
|
||||
// Используем список из /cabinet/subscriptions/list — пустой массив означает «нет подписок»,
|
||||
// и тогда показываем TrialOfferCard. Без этой ветки multi-tariff юзер никогда не видел триал.
|
||||
const hasNoSubscription = isMultiTariff
|
||||
? multiSubData !== undefined && (multiSubData.subscriptions?.length ?? 0) === 0
|
||||
: subscriptionResponse?.has_subscription === false && !subLoading;
|
||||
|
||||
// Show onboarding for new users after data loads
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user