2
0

🛂 (whatsapp) Disable whatsapp by default on duplication

This commit is contained in:
Baptiste Arnaud
2023-10-03 10:40:38 +02:00
parent 60c06aa9a9
commit 3292cccf51
3 changed files with 19 additions and 3 deletions

View File

@ -80,7 +80,7 @@ export const createTypebot = authenticatedProcedure
: defaultGroups(),
theme: typebot.theme ? typebot.theme : defaultTheme,
settings: typebot.settings
? sanitizeSettings(typebot.settings, workspace.plan)
? sanitizeSettings(typebot.settings, workspace.plan, 'create')
: defaultSettings({
isBrandingEnabled: workspace.plan === Plan.FREE,
}),

View File

@ -142,7 +142,11 @@ export const updateTypebot = authenticatedProcedure
: undefined,
theme: typebot.theme ? typebot.theme : undefined,
settings: typebot.settings
? sanitizeSettings(typebot.settings, existingTypebot.workspace.plan)
? sanitizeSettings(
typebot.settings,
existingTypebot.workspace.plan,
'update'
)
: undefined,
folderId: typebot.folderId,
variables: typebot.variables,

View File

@ -9,7 +9,8 @@ import {
export const sanitizeSettings = (
settings: Typebot['settings'],
workspacePlan: Plan
workspacePlan: Plan,
mode: 'create' | 'update'
): Typebot['settings'] => ({
...settings,
general: {
@ -17,6 +18,17 @@ export const sanitizeSettings = (
isBrandingEnabled:
workspacePlan === Plan.FREE ? false : settings.general.isBrandingEnabled,
},
whatsApp: settings.whatsApp
? {
...settings.whatsApp,
isEnabled:
mode === 'create'
? false
: workspacePlan === Plan.FREE
? false
: settings.whatsApp.isEnabled,
}
: undefined,
})
export const sanitizeGroups =