adsasdasd

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-08 11:51:00 +00:00
parent affa783a4f
commit da3b45d1c7
14 changed files with 1763 additions and 19 deletions

View File

@@ -328,8 +328,11 @@ export default function PlansAndBillingPage() {
const currentSubscription = subscriptions.find((sub) => sub.status === 'active') || subscriptions[0];
const currentPlanId = typeof currentSubscription?.plan === 'object' ? currentSubscription.plan.id : currentSubscription?.plan;
const currentPlan = plans.find((p) => p.id === currentPlanId);
const hasActivePlan = Boolean(currentPlanId);
// Fallback to account plan if subscription is missing
const accountPlanId = user?.account?.plan?.id;
const effectivePlanId = currentPlanId || accountPlanId;
const currentPlan = plans.find((p) => p.id === effectivePlanId) || user?.account?.plan;
const hasActivePlan = Boolean(effectivePlanId);
const hasPaymentMethods = paymentMethods.length > 0;
const subscriptionStatus = currentSubscription?.status || (hasActivePlan ? 'active' : 'none');
const hasPendingManualPayment = payments.some((p) => p.status === 'pending_approval');

View File

@@ -196,12 +196,12 @@ export interface PendingPayment extends Payment {
// ============================================================================
export async function getCreditBalance(): Promise<CreditBalance> {
// Use canonical balance endpoint (transactions/balance) and coalesce concurrent calls
// Use canonical balance endpoint (credits/balance) per unified API structure
if (creditBalanceInFlight) {
return creditBalanceInFlight;
}
creditBalanceInFlight = fetchAPI('/v1/billing/transactions/balance/');
creditBalanceInFlight = fetchAPI('/v1/billing/credits/balance/');
try {
return await creditBalanceInFlight;
} finally {
@@ -214,7 +214,7 @@ export async function getCreditTransactions(): Promise<{
count: number;
current_balance?: number;
}> {
return fetchAPI('/v1/billing/transactions/');
return fetchAPI('/v1/billing/credits/transactions/');
}
// ============================================================================