mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Fix: remove hacks on determining service limits
This commit is contained in:
1 parent
1c0af8d5be
commit
2cad4301f2
1 file changed
+11
-13
+11
-13
@@ -154,20 +154,18 @@ export type PlanServices =
|
||||
export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan?: Plan): number {
|
||||
if (!isCloud) return 0;
|
||||
if (!serviceId) return 0;
|
||||
const info = get(plansInfo);
|
||||
if (!info) return 0;
|
||||
plan ??= info.get(tier ?? get(organization)?.billingPlan);
|
||||
// members are no longer a variable on plan itself!
|
||||
// the correct info for members/seats, resides in `addons`.
|
||||
// plan > addons > seats/others
|
||||
|
||||
plan ??= get(currentPlan);
|
||||
|
||||
if (tier) {
|
||||
const info = get(plansInfo);
|
||||
if (!info) return 0;
|
||||
plan ??= info.get(tier);
|
||||
}
|
||||
|
||||
if (serviceId === 'members') {
|
||||
// pro and scale plans have unlimited seats (per-project NEW pricing model)
|
||||
const currentTier = tier ?? get(organization)?.billingPlan;
|
||||
if (currentTier === BillingPlan.PRO || currentTier === BillingPlan.SCALE) {
|
||||
return Infinity; // unlimited seats for Pro and Scale plans
|
||||
}
|
||||
// Free plan still has 1 member limit
|
||||
return (plan?.['addons']['seats'] || [])['limit'] ?? 1;
|
||||
if (!(plan.addons.seats?.supported ?? false)) return Infinity;
|
||||
return plan.addons.seats?.limit ?? 1;
|
||||
}
|
||||
|
||||
return plan?.[serviceId] ?? 0;
|
||||
|
||||
Reference in new issue
Block a user