🚸 Auto disable whatsapp if plan does not have pro…
This commit is contained in:
@ -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({
|
const newTypebot = await prisma.typebot.update({
|
||||||
where: {
|
where: {
|
||||||
id: existingTypebot.id,
|
id: existingTypebot.id,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { hasProPerks } from '@/features/billing/helpers/hasProPerks'
|
||||||
import prisma from '@typebot.io/lib/prisma'
|
import prisma from '@typebot.io/lib/prisma'
|
||||||
import { Plan } from '@typebot.io/prisma'
|
import { Plan } from '@typebot.io/prisma'
|
||||||
import { Block, Typebot } from '@typebot.io/schemas'
|
import { Block, Typebot } from '@typebot.io/schemas'
|
||||||
@ -27,9 +28,9 @@ export const sanitizeSettings = (
|
|||||||
isEnabled:
|
isEnabled:
|
||||||
mode === 'create'
|
mode === 'create'
|
||||||
? false
|
? false
|
||||||
: workspacePlan === Plan.FREE
|
: hasProPerks({ plan: workspacePlan })
|
||||||
? false
|
? settings.whatsApp.isEnabled
|
||||||
: settings.whatsApp.isEnabled,
|
: false,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user