diff --git a/apps/builder/src/components/UnlockPlanAlertInfo.tsx b/apps/builder/src/components/UnlockPlanAlertInfo.tsx index c73d41025..2102e043d 100644 --- a/apps/builder/src/components/UnlockPlanAlertInfo.tsx +++ b/apps/builder/src/components/UnlockPlanAlertInfo.tsx @@ -15,13 +15,11 @@ import { import { useI18n } from '@/locales' type Props = { - contentLabel: React.ReactNode buttonLabel?: string } & AlertProps & Pick export const UnlockPlanAlertInfo = ({ - contentLabel, buttonLabel, type, excludedPlans, @@ -39,7 +37,7 @@ export const UnlockPlanAlertInfo = ({ > - {contentLabel} + {props.children} diff --git a/apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx b/apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx index 3eeac1c0c..f4b3adb1c 100644 --- a/apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx +++ b/apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppModal.tsx @@ -39,6 +39,9 @@ import { NumberInput } from '@/components/inputs' import { defaultSessionExpiryTimeout } from '@typebot.io/schemas/features/whatsapp' import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings' import { isDefined } from '@typebot.io/lib/utils' +import { hasProPerks } from '@/features/billing/helpers/hasProPerks' +import { UnlockPlanAlertInfo } from '@/components/UnlockPlanAlertInfo' +import { PlanTag } from '@/features/billing/components/PlanTag' export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => { const { typebot, updateTypebot, isPublished } = useTypebot() @@ -175,6 +178,12 @@ export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => { + {!hasProPerks(workspace) && ( + + Upgrade your workspace to to be able to + enable WhatsApp integration. + + )} {!isPublished && phoneNumberData?.id && ( You have modifications that can be published. )} @@ -269,6 +278,7 @@ export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => { { <> {chatsLimitPercentage > ALERT_CHATS_PERCENT_THRESHOLD && ( - - Your workspace collected{' '} - {chatsLimitPercentage}% of your total chats - limit this month. Upgrade your plan to continue chatting with - your customers beyond this limit. - - } - buttonLabel="Upgrade" - /> + + Your workspace collected {chatsLimitPercentage}% of + your total chats limit this month. Upgrade your plan to continue + chatting with your customers beyond this limit. + )} diff --git a/apps/builder/src/features/typebot/api/updateTypebot.ts b/apps/builder/src/features/typebot/api/updateTypebot.ts index b4fa39dfc..785dbcec4 100644 --- a/apps/builder/src/features/typebot/api/updateTypebot.ts +++ b/apps/builder/src/features/typebot/api/updateTypebot.ts @@ -119,12 +119,12 @@ export const updateTypebot = authenticatedProcedure } if ( - typebot.whatsAppCredentialsId && + typebot.settings?.whatsApp?.isEnabled && !hasProPerks(existingTypebot.workspace) ) { throw new TRPCError({ code: 'BAD_REQUEST', - message: 'WhatsApp is only available for Pro workspaces', + message: 'WhatsApp can be enabled only on a Pro workspaces', }) } diff --git a/apps/builder/src/features/workspace/components/MembersList.tsx b/apps/builder/src/features/workspace/components/MembersList.tsx index 2050bb79d..defa31c70 100644 --- a/apps/builder/src/features/workspace/components/MembersList.tsx +++ b/apps/builder/src/features/workspace/components/MembersList.tsx @@ -103,7 +103,9 @@ export const MembersList = () => { return ( {!canInviteNewMember && ( - + + {scopedT('unlockBanner.label')} + )} {isDefined(seatsLimit) && ( diff --git a/apps/builder/src/pages/api/stripe/webhook.ts b/apps/builder/src/pages/api/stripe/webhook.ts index 290aa3bf0..7f7d18104 100644 --- a/apps/builder/src/pages/api/stripe/webhook.ts +++ b/apps/builder/src/pages/api/stripe/webhook.ts @@ -191,13 +191,18 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => { await prisma.typebot.updateMany({ where: { id: typebot.id }, data: { - whatsAppCredentialsId: null, settings: { ...settings, general: { ...settings.general, isBrandingEnabled: true, }, + whatsApp: settings.whatsApp + ? { + ...settings.whatsApp, + isEnabled: false, + } + : undefined, }, }, })