MCPcopy Index your code
hub / github.com/simstudioai/sim / mapToTeamPlanName

Function mapToTeamPlanName

apps/sim/lib/billing/organizations/provision-seat.ts:240–255  ·  view source on GitHub ↗

* Map a Pro (or legacy) plan to a Team tier, choosing the smallest Team tier * whose credit allowance is at least the current plan's so an upgrade never * silently drops credits. Returns `null` when no eligible Team tier exists * (e.g. a Max owner when the Team Max price is unconfigured) so the c

(plan: string)

Source from the content-addressed store, hash-verified

238 * surface `upgrade-required` instead of downgrading.
239 */
240function mapToTeamPlanName(plan: string): string | null {
241 if (isTeam(plan)) return plan
242
243 const credits = getPlanTierCredits(plan)
244 const eligibleTiers = [...CREDIT_TIERS]
245 .filter((tier) => tier.credits >= credits)
246 .sort((a, b) => a.credits - b.credits)
247
248 for (const tier of eligibleTiers) {
249 const candidate = buildPlanName('team', tier.credits)
250 if (getPlanByName(candidate)) {
251 return candidate
252 }
253 }
254 return null
255}

Callers 2

Calls 4

isTeamFunction · 0.90
getPlanTierCreditsFunction · 0.90
buildPlanNameFunction · 0.90
getPlanByNameFunction · 0.90

Tested by

no test coverage detected