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:
Fringg
2026-05-13 05:31:22 +03:00
parent 6ffd0ae824
commit 7c10843d9c
2 changed files with 58 additions and 4 deletions

View File

@@ -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(() => {