Skip to content

Commit

Permalink
🚸 Auto disable whatsapp if plan does not have pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 20, 2024
1 parent c72052c commit 7c23b95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 0 additions & 10 deletions apps/builder/src/features/typebot/api/updateTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions apps/builder/src/features/typebot/helpers/sanitizers.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit 7c23b95

Please sign in to comment.