From 2d4b18b1e8a96f01292f307fe2f4d555be6a705d Mon Sep 17 00:00:00 2001 From: Catalin Pit <25515812+catalinpit@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:34:15 +0200 Subject: [PATCH] feat: limit free teams to 1 for platform plan --- packages/ee/server-only/util/is-document-platform.ts | 2 +- packages/lib/server-only/team/create-team.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/ee/server-only/util/is-document-platform.ts b/packages/ee/server-only/util/is-document-platform.ts index 67d9d6acd..2c78d237e 100644 --- a/packages/ee/server-only/util/is-document-platform.ts +++ b/packages/ee/server-only/util/is-document-platform.ts @@ -5,7 +5,7 @@ import type { Document, Subscription } from '@documenso/prisma/client'; import { getPlatformPlanPriceIds } from '../stripe/get-platform-plan-prices'; -export type IsDocumentPlatformOptions = Pick; +export type IsDocumentPlatformOptions = Pick; /** * Whether the user is platform, or has permission to use platform features on diff --git a/packages/lib/server-only/team/create-team.ts b/packages/lib/server-only/team/create-team.ts index 210187c5c..b5eddc42f 100644 --- a/packages/lib/server-only/team/create-team.ts +++ b/packages/lib/server-only/team/create-team.ts @@ -5,6 +5,7 @@ import { z } from 'zod'; import { createTeamCustomer } from '@documenso/ee/server-only/stripe/create-team-customer'; import { getTeamRelatedPrices } from '@documenso/ee/server-only/stripe/get-team-related-prices'; import { mapStripeSubscriptionToPrismaUpsertAction } from '@documenso/ee/server-only/stripe/webhook/on-subscription-updated'; +import { isDocumentPlatform as isUserPlatformPlan } from '@documenso/ee/server-only/util/is-document-platform'; import { IS_BILLING_ENABLED } from '@documenso/lib/constants/app'; import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error'; import { subscriptionsContainsActivePlan } from '@documenso/lib/utils/billing'; @@ -60,6 +61,11 @@ export const createTeam = async ({ }, }); + const isPlatformPlan = await isUserPlatformPlan({ + userId: user.id, + teamId: null, + }); + let isPaymentRequired = IS_BILLING_ENABLED(); let customerId: string | null = null;