mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
fix: promocode multi-tariff support in cabinet
- Balance page: handle select_subscription response — show subscription picker when promo code adds days and user has multiple tariffs - API: activatePromocode now accepts optional subscriptionId - AdminPromocodeCreate: show trial tariff info when creating trial_subscription promo code, warn if no trial tariff configured
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
PromoCodeUpdateRequest,
|
||||
PromoGroup,
|
||||
} from '../api/promocodes';
|
||||
import { tariffsApi } from '../api/tariffs';
|
||||
import { usePlatform } from '../platform/hooks/usePlatform';
|
||||
|
||||
// Icons
|
||||
@@ -69,6 +70,15 @@ export default function AdminPromocodeCreate() {
|
||||
|
||||
const promoGroups: PromoGroup[] = promoGroupsData?.items || [];
|
||||
|
||||
// Fetch tariffs to show trial tariff info
|
||||
const { data: tariffsData } = useQuery({
|
||||
queryKey: ['admin-tariffs-for-promo'],
|
||||
queryFn: () => tariffsApi.getTariffs(true),
|
||||
enabled: type === 'trial_subscription',
|
||||
});
|
||||
|
||||
const trialTariff = tariffsData?.tariffs?.find((t) => t.is_trial_available) || null;
|
||||
|
||||
// Fetch promocode for editing
|
||||
const { isLoading: isLoadingPromocode } = useQuery({
|
||||
queryKey: ['admin-promocode', id],
|
||||
@@ -301,6 +311,31 @@ export default function AdminPromocodeCreate() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{type === 'trial_subscription' && (
|
||||
<div className="rounded-lg border border-dark-600 bg-dark-700/50 p-3">
|
||||
{trialTariff ? (
|
||||
<div className="text-sm">
|
||||
<span className="text-dark-400">
|
||||
{t('admin.promocodes.form.trialTariffInfo', 'Будет выдан тариф:')}
|
||||
</span>{' '}
|
||||
<span className="font-medium text-accent-400">{trialTariff.name}</span>
|
||||
<span className="text-dark-500">
|
||||
{' '}
|
||||
({trialTariff.traffic_limit_gb} GB, {trialTariff.device_limit}{' '}
|
||||
{t('admin.promocodes.form.devices', 'устр.')})
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm text-warning-400">
|
||||
{t(
|
||||
'admin.promocodes.form.noTrialTariff',
|
||||
'⚠️ Триальный тариф не настроен. Отметьте тариф как «доступен для триала» в настройках тарифов.',
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{type === 'promo_group' && (
|
||||
<div>
|
||||
<label className="mb-2 block text-sm font-medium text-dark-300">
|
||||
|
||||
Reference in New Issue
Block a user