Browse Source

fix custom plan subscription issues

pull/67/head
isra el 11 months ago
parent
commit
a01cf9bbaa
  1. 6
      api/src/billing/billing.service.ts
  2. 2
      web/app/(app)/dashboard/(components)/upgrade-to-pro-alert.tsx

6
api/src/billing/billing.service.ts

@ -126,13 +126,13 @@ export class BillingService {
const user = await this.userModel.findById(new Types.ObjectId(userId)) const user = await this.userModel.findById(new Types.ObjectId(userId))
const plans = await this.planModel.find() const plans = await this.planModel.find()
const customPlan = plans.find((plan) => plan.name === 'custom')
const customPlans = plans.filter((plan) => plan.name?.startsWith('custom'))
const proPlan = plans.find((plan) => plan.name === 'pro') const proPlan = plans.find((plan) => plan.name === 'pro')
const freePlan = plans.find((plan) => plan.name === 'free') const freePlan = plans.find((plan) => plan.name === 'free')
const customPlanSubscription = await this.subscriptionModel.findOne({ const customPlanSubscription = await this.subscriptionModel.findOne({
user: user._id, user: user._id,
plan: customPlan._id,
plan: { $in: customPlans.map((plan) => plan._id) },
isActive: true, isActive: true,
}) })
@ -321,7 +321,7 @@ export class BillingService {
plan = await this.planModel.findById(subscription.plan) plan = await this.planModel.findById(subscription.plan)
} }
if (plan.name === 'custom') {
if (plan.name?.startsWith('custom')) {
// TODO: for now custom plans are unlimited // TODO: for now custom plans are unlimited
return true return true
} }

2
web/app/(app)/dashboard/(components)/upgrade-to-pro-alert.tsx

@ -51,7 +51,7 @@ export default function UpgradeToProAlert() {
return null return null
} }
if (['pro', 'custom'].includes(currentSubscription?.plan?.name)) {
if (currentSubscription?.plan?.name !== 'free') {
return null return null
} }

Loading…
Cancel
Save