2
0

🚸 Auto disable whatsapp if plan does not have pro…

This commit is contained in:
Baptiste Arnaud
2024-03-20 17:11:17 +01:00
parent c72052cb9d
commit 7c23b958c4
2 changed files with 4 additions and 13 deletions

View File

@ -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,

View File

@ -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,
})