feat: show autopay/auto-charge status on subscription cards, invalidate list on toggle

- SubscriptionListCard: always show autopay status (green check / red cross)
  for regular tariffs, show auto-charge status for daily tariffs
- Hide autopay for trial subscriptions
- Autopay mutation: invalidate subscriptions-list for instant UI update
- Types: added is_daily, is_daily_paused to SubscriptionListItem
This commit is contained in:
c0mrade
2026-03-24 12:28:02 +03:00
parent b0421b94a6
commit 871b4769aa
3 changed files with 31 additions and 14 deletions

View File

@@ -191,20 +191,34 @@ export default function SubscriptionListCard({
</svg>
{formatDate(subscription.end_date, i18n.language)}
</span>
{subscription.autopay_enabled && (
<span className="flex items-center gap-1 text-emerald-400/70">
<svg
className="h-3 w-3"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2.5}
>
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 12.75l6 6 9-13.5" />
</svg>
{t('subscription.autopay', 'Автопродление')}
</span>
)}
{!isTrial &&
(() => {
const isDaily = subscription.is_daily;
const enabled = isDaily ? !subscription.is_daily_paused : subscription.autopay_enabled;
const label = isDaily
? t('subscription.dailyAutoCharge', 'Автосписание')
: t('subscription.autopay', 'Автопродление');
return (
<span
className={`flex items-center gap-1 ${enabled ? 'text-emerald-400/70' : 'text-red-400/50'}`}
>
<svg
className="h-3 w-3"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2.5}
>
{enabled ? (
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 12.75l6 6 9-13.5" />
) : (
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
)}
</svg>
{label}
</span>
);
})()}
</div>
</button>
);

View File

@@ -234,6 +234,7 @@ export default function Subscription() {
subscriptionApi.updateAutopay(enabled, undefined, subscriptionId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['subscription', subscriptionId] });
queryClient.invalidateQueries({ queryKey: ['subscriptions-list'] });
},
});

View File

@@ -123,6 +123,8 @@ export interface SubscriptionListItem {
subscription_url: string | null;
subscription_crypto_link: string | null;
is_trial: boolean;
is_daily?: boolean;
is_daily_paused?: boolean;
autopay_enabled: boolean;
connected_squads: string[] | null;
}