From 7c23b958c47cb031654756eaf5cc46d6caaca1ad Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Wed, 20 Mar 2024 17:11:17 +0100 Subject: [PATCH] =?UTF-8?q?:children=5Fcrossing:=20Auto=20disable=20whatsa?= =?UTF-8?q?pp=20if=20plan=20does=20not=20have=20pro=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/builder/src/features/typebot/api/updateTypebot.ts | 10 ---------- .../builder/src/features/typebot/helpers/sanitizers.ts | 7 ++++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/apps/builder/src/features/typebot/api/updateTypebot.ts b/apps/builder/src/features/typebot/api/updateTypebot.ts index 6a49180ff..5c9f38205 100644 --- a/apps/builder/src/features/typebot/api/updateTypebot.ts +++ b/apps/builder/src/features/typebot/api/updateTypebot.ts @@ -158,16 +158,6 @@ export const updateTypebot = authenticatedProcedure }) } - if ( - typebot.settings?.whatsApp?.isEnabled && - !hasProPerks(existingTypebot.workspace) - ) { - throw new TRPCError({ - code: 'BAD_REQUEST', - message: 'WhatsApp can be enabled only on a Pro workspaces', - }) - } - const newTypebot = await prisma.typebot.update({ where: { id: existingTypebot.id, diff --git a/apps/builder/src/features/typebot/helpers/sanitizers.ts b/apps/builder/src/features/typebot/helpers/sanitizers.ts index 4d27f7058..cf42077b2 100644 --- a/apps/builder/src/features/typebot/helpers/sanitizers.ts +++ b/apps/builder/src/features/typebot/helpers/sanitizers.ts @@ -1,3 +1,4 @@ +import { hasProPerks } from '@/features/billing/helpers/hasProPerks' import prisma from '@typebot.io/lib/prisma' import { Plan } from '@typebot.io/prisma' import { Block, Typebot } from '@typebot.io/schemas' @@ -27,9 +28,9 @@ export const sanitizeSettings = ( isEnabled: mode === 'create' ? false - : workspacePlan === Plan.FREE - ? false - : settings.whatsApp.isEnabled, + : hasProPerks({ plan: workspacePlan }) + ? settings.whatsApp.isEnabled + : false, } : undefined, })