fix(billing): resolve react query cache conflict rendering undefined values, update enterprise CTA label and show plan cards for all tiers
This commit is contained in:
@@ -54,17 +54,18 @@ export function BillingPlans() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: quotas } = useQuery({
|
const { data: usageData } = useQuery({
|
||||||
queryKey: ['usage', 'current'],
|
queryKey: ['usage', 'current'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const res = await fetch('/api/usage/current');
|
const res = await fetch('/api/usage/current');
|
||||||
if (!res.ok) throw new Error('Failed to fetch quotas');
|
if (!res.ok) throw new Error('Failed to fetch quotas');
|
||||||
const data = await res.json();
|
return res.json();
|
||||||
return data.quotas as Record<string, { remaining: number; limit: number; used: number }>;
|
|
||||||
},
|
},
|
||||||
refetchInterval: 30000,
|
refetchInterval: 30000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const quotas = usageData?.quotas;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const sessionId = params.get('session_id');
|
const sessionId = params.get('session_id');
|
||||||
@@ -455,14 +456,13 @@ export function BillingPlans() {
|
|||||||
{/* Billing History (Only for paid users) */}
|
{/* Billing History (Only for paid users) */}
|
||||||
{isPaid && <BillingHistory />}
|
{isPaid && <BillingHistory />}
|
||||||
|
|
||||||
{/* Interval Toggle & Plan Cards (Only for BASIC/Free users) */}
|
{/* Interval Toggle & Plan Cards */}
|
||||||
{!isPaid && (
|
<div className="space-y-8 pt-6 border-t border-border/40">
|
||||||
<div className="space-y-8 pt-6 border-t border-border/40">
|
<div className="text-center space-y-2">
|
||||||
<div className="text-center space-y-2">
|
<h3 className="text-xs font-bold uppercase tracking-[0.2em] text-concrete">
|
||||||
<h3 className="text-xs font-bold uppercase tracking-[0.2em] text-concrete">
|
{t('billing.upgradePlan') || 'Changer de plan'}
|
||||||
{t('billing.upgradePlan') || 'Changer de plan'}
|
</h3>
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{billingEnabled && (
|
{billingEnabled && (
|
||||||
<div className="flex items-center gap-2 justify-center">
|
<div className="flex items-center gap-2 justify-center">
|
||||||
@@ -541,7 +541,6 @@ export function BillingPlans() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Footer Info */}
|
{/* Footer Info */}
|
||||||
<div className="bg-slate-50 dark:bg-black/20 rounded-[32px] p-8 border border-border/40 flex flex-col md:flex-row items-center justify-between gap-8">
|
<div className="bg-slate-50 dark:bg-black/20 rounded-[32px] p-8 border border-border/40 flex flex-col md:flex-row items-center justify-between gap-8">
|
||||||
|
|||||||
@@ -2860,7 +2860,7 @@
|
|||||||
"businessFeature4": "1,000 chat messages / month",
|
"businessFeature4": "1,000 chat messages / month",
|
||||||
"enterpriseTitle": "Enterprise",
|
"enterpriseTitle": "Enterprise",
|
||||||
"enterpriseDescription": "Custom quotas, SSO, priority support.",
|
"enterpriseDescription": "Custom quotas, SSO, priority support.",
|
||||||
"contactSales": "Contact Sales",
|
"contactSales": "Contact us",
|
||||||
"startCheckout": "Get Started",
|
"startCheckout": "Get Started",
|
||||||
"checkoutLoading": "Loading checkout…",
|
"checkoutLoading": "Loading checkout…",
|
||||||
"checkoutSuccess": "Subscription activated! Welcome to {tier}.",
|
"checkoutSuccess": "Subscription activated! Welcome to {tier}.",
|
||||||
|
|||||||
@@ -2864,7 +2864,7 @@
|
|||||||
"businessFeature4": "1 000 messages de chat / mois",
|
"businessFeature4": "1 000 messages de chat / mois",
|
||||||
"enterpriseTitle": "Entreprise",
|
"enterpriseTitle": "Entreprise",
|
||||||
"enterpriseDescription": "Quotas personnalisés, SSO, support prioritaire.",
|
"enterpriseDescription": "Quotas personnalisés, SSO, support prioritaire.",
|
||||||
"contactSales": "Contacter les ventes",
|
"contactSales": "Contactez-nous",
|
||||||
"startCheckout": "Commencer",
|
"startCheckout": "Commencer",
|
||||||
"checkoutLoading": "Chargement du paiement…",
|
"checkoutLoading": "Chargement du paiement…",
|
||||||
"checkoutSuccess": "Abonnement activé ! Bienvenue dans {tier}.",
|
"checkoutSuccess": "Abonnement activé ! Bienvenue dans {tier}.",
|
||||||
|
|||||||
Reference in New Issue
Block a user