From da6c18310bc07df30da61ee843d15dc0d1a8695c Mon Sep 17 00:00:00 2001 From: isra el Date: Mon, 24 Feb 2025 00:59:36 +0300 Subject: [PATCH] fix my-account page issues --- api/src/billing/billing.service.ts | 15 +++++++------- .../(components)/account-settings.tsx | 20 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/api/src/billing/billing.service.ts b/api/src/billing/billing.service.ts index 68741b5..265b03f 100644 --- a/api/src/billing/billing.service.ts +++ b/api/src/billing/billing.service.ts @@ -51,15 +51,16 @@ export class BillingService { }) .populate('plan') - let plan = null - - if (!subscription) { - plan = await this.planModel.findOne({ name: 'free' }) - } else { - plan = await this.planModel.findById(subscription.plan) + if (subscription) { + return subscription } - return plan + const plan = await this.planModel.findOne({ name: 'free' }) + + return { + plan, + isActive: true, + } } async getCheckoutUrl({ diff --git a/web/app/(app)/dashboard/(components)/account-settings.tsx b/web/app/(app)/dashboard/(components)/account-settings.tsx index c802557..1166d50 100644 --- a/web/app/(app)/dashboard/(components)/account-settings.tsx +++ b/web/app/(app)/dashboard/(components)/account-settings.tsx @@ -270,7 +270,7 @@ export default function AccountSettings() {

Quota

- {currentSubscription?.quota} + {currentSubscription?.plan?.quota}

@@ -282,10 +282,10 @@ export default function AccountSettings() { Daily

- {currentSubscription?.dailyLimit === -1 + {currentSubscription?.plan?.dailyLimit === -1 ? 'Unlimited' - : currentSubscription?.dailyLimit} - {currentSubscription?.dailyLimit === -1 && ( + : currentSubscription?.plan?.dailyLimit} + {currentSubscription?.plan?.dailyLimit === -1 && ( @@ -306,10 +306,10 @@ export default function AccountSettings() { Monthly

- {currentSubscription?.monthlyLimit === -1 + {currentSubscription?.plan?.monthlyLimit === -1 ? 'Unlimited' - : currentSubscription?.monthlyLimit.toLocaleString()} - {currentSubscription?.monthlyLimit === -1 && ( + : currentSubscription?.plan?.monthlyLimit?.toLocaleString()} + {currentSubscription?.plan?.monthlyLimit === -1 && ( @@ -328,10 +328,10 @@ export default function AccountSettings() {

Bulk

- {currentSubscription?.bulkSendLimit === -1 + {currentSubscription?.plan?.bulkSendLimit === -1 ? 'Unlimited' - : currentSubscription?.bulkSendLimit} - {currentSubscription?.bulkSendLimit === -1 && ( + : currentSubscription?.plan?.bulkSendLimit} + {currentSubscription?.plan?.bulkSendLimit === -1 && (