mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
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:
@@ -191,20 +191,34 @@ export default function SubscriptionListCard({
|
|||||||
</svg>
|
</svg>
|
||||||
{formatDate(subscription.end_date, i18n.language)}
|
{formatDate(subscription.end_date, i18n.language)}
|
||||||
</span>
|
</span>
|
||||||
{subscription.autopay_enabled && (
|
{!isTrial &&
|
||||||
<span className="flex items-center gap-1 text-emerald-400/70">
|
(() => {
|
||||||
<svg
|
const isDaily = subscription.is_daily;
|
||||||
className="h-3 w-3"
|
const enabled = isDaily ? !subscription.is_daily_paused : subscription.autopay_enabled;
|
||||||
viewBox="0 0 24 24"
|
const label = isDaily
|
||||||
fill="none"
|
? t('subscription.dailyAutoCharge', 'Автосписание')
|
||||||
stroke="currentColor"
|
: t('subscription.autopay', 'Автопродление');
|
||||||
strokeWidth={2.5}
|
return (
|
||||||
>
|
<span
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 12.75l6 6 9-13.5" />
|
className={`flex items-center gap-1 ${enabled ? 'text-emerald-400/70' : 'text-red-400/50'}`}
|
||||||
</svg>
|
>
|
||||||
{t('subscription.autopay', 'Автопродление')}
|
<svg
|
||||||
</span>
|
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>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ export default function Subscription() {
|
|||||||
subscriptionApi.updateAutopay(enabled, undefined, subscriptionId),
|
subscriptionApi.updateAutopay(enabled, undefined, subscriptionId),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['subscription', subscriptionId] });
|
queryClient.invalidateQueries({ queryKey: ['subscription', subscriptionId] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['subscriptions-list'] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ export interface SubscriptionListItem {
|
|||||||
subscription_url: string | null;
|
subscription_url: string | null;
|
||||||
subscription_crypto_link: string | null;
|
subscription_crypto_link: string | null;
|
||||||
is_trial: boolean;
|
is_trial: boolean;
|
||||||
|
is_daily?: boolean;
|
||||||
|
is_daily_paused?: boolean;
|
||||||
autopay_enabled: boolean;
|
autopay_enabled: boolean;
|
||||||
connected_squads: string[] | null;
|
connected_squads: string[] | null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user