🚸 (whatsapp) Improve upgrade plan for whatsapp notice
This commit is contained in:
@@ -15,13 +15,11 @@ import {
|
|||||||
import { useI18n } from '@/locales'
|
import { useI18n } from '@/locales'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
contentLabel: React.ReactNode
|
|
||||||
buttonLabel?: string
|
buttonLabel?: string
|
||||||
} & AlertProps &
|
} & AlertProps &
|
||||||
Pick<ChangePlanModalProps, 'type' | 'excludedPlans'>
|
Pick<ChangePlanModalProps, 'type' | 'excludedPlans'>
|
||||||
|
|
||||||
export const UnlockPlanAlertInfo = ({
|
export const UnlockPlanAlertInfo = ({
|
||||||
contentLabel,
|
|
||||||
buttonLabel,
|
buttonLabel,
|
||||||
type,
|
type,
|
||||||
excludedPlans,
|
excludedPlans,
|
||||||
@@ -39,7 +37,7 @@ export const UnlockPlanAlertInfo = ({
|
|||||||
>
|
>
|
||||||
<HStack>
|
<HStack>
|
||||||
<AlertIcon />
|
<AlertIcon />
|
||||||
<Text>{contentLabel}</Text>
|
<Text>{props.children}</Text>
|
||||||
</HStack>
|
</HStack>
|
||||||
<Button
|
<Button
|
||||||
colorScheme={props.status === 'warning' ? 'orange' : 'blue'}
|
colorScheme={props.status === 'warning' ? 'orange' : 'blue'}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import { ParentModalProvider } from '@/features/graph/providers/ParentModalProvi
|
|||||||
import { isWhatsAppAvailable } from '@/features/telemetry/posthog'
|
import { isWhatsAppAvailable } from '@/features/telemetry/posthog'
|
||||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
||||||
import { hasProPerks } from '@/features/billing/helpers/hasProPerks'
|
import { hasProPerks } from '@/features/billing/helpers/hasProPerks'
|
||||||
import { ChangePlanModal } from '@/features/billing/components/ChangePlanModal'
|
|
||||||
import { LockTag } from '@/features/billing/components/LockTag'
|
import { LockTag } from '@/features/billing/components/LockTag'
|
||||||
import { Plan } from '@typebot.io/prisma'
|
import { Plan } from '@typebot.io/prisma'
|
||||||
|
|
||||||
@@ -106,18 +105,9 @@ export const integrationsList = [
|
|||||||
logo={<WhatsAppLogo height={100} width="70px" />}
|
logo={<WhatsAppLogo height={100} width="70px" />}
|
||||||
label="WhatsApp"
|
label="WhatsApp"
|
||||||
lockTagPlan={hasProPerks(workspace) ? undefined : 'PRO'}
|
lockTagPlan={hasProPerks(workspace) ? undefined : 'PRO'}
|
||||||
modal={({ onClose, isOpen }) =>
|
modal={({ onClose, isOpen }) => (
|
||||||
hasProPerks(workspace) ? (
|
<WhatsAppModal isOpen={isOpen} onClose={onClose} {...props} />
|
||||||
<WhatsAppModal isOpen={isOpen} onClose={onClose} {...props} />
|
)}
|
||||||
) : (
|
|
||||||
<ChangePlanModal
|
|
||||||
isOpen={isOpen}
|
|
||||||
onClose={onClose}
|
|
||||||
excludedPlans={['STARTER']}
|
|
||||||
type="deploy on WhatsApp"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</ParentModalProvider>
|
</ParentModalProvider>
|
||||||
|
|||||||
@@ -397,12 +397,15 @@ const PhoneNumber = ({
|
|||||||
<HStack>
|
<HStack>
|
||||||
<Text>
|
<Text>
|
||||||
Go to your{' '}
|
Go to your{' '}
|
||||||
<TextLink
|
<Button
|
||||||
|
as={Link}
|
||||||
href={`https://developers.facebook.com/apps/${appId}/whatsapp-business/wa-dev-console`}
|
href={`https://developers.facebook.com/apps/${appId}/whatsapp-business/wa-dev-console`}
|
||||||
isExternal
|
isExternal
|
||||||
|
rightIcon={<ExternalLinkIcon />}
|
||||||
|
size="sm"
|
||||||
>
|
>
|
||||||
WhatsApp Dev Console
|
WhatsApp Dev Console{' '}
|
||||||
</TextLink>
|
</Button>
|
||||||
</Text>
|
</Text>
|
||||||
</HStack>
|
</HStack>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ import { NumberInput } from '@/components/inputs'
|
|||||||
import { defaultSessionExpiryTimeout } from '@typebot.io/schemas/features/whatsapp'
|
import { defaultSessionExpiryTimeout } from '@typebot.io/schemas/features/whatsapp'
|
||||||
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
||||||
import { isDefined } from '@typebot.io/lib/utils'
|
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 => {
|
export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => {
|
||||||
const { typebot, updateTypebot, isPublished } = useTypebot()
|
const { typebot, updateTypebot, isPublished } = useTypebot()
|
||||||
@@ -175,6 +178,12 @@ export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => {
|
|||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody as={Stack} spacing="6">
|
<ModalBody as={Stack} spacing="6">
|
||||||
|
{!hasProPerks(workspace) && (
|
||||||
|
<UnlockPlanAlertInfo excludedPlans={['STARTER']}>
|
||||||
|
Upgrade your workspace to <PlanTag plan="PRO" /> to be able to
|
||||||
|
enable WhatsApp integration.
|
||||||
|
</UnlockPlanAlertInfo>
|
||||||
|
)}
|
||||||
{!isPublished && phoneNumberData?.id && (
|
{!isPublished && phoneNumberData?.id && (
|
||||||
<AlertInfo>You have modifications that can be published.</AlertInfo>
|
<AlertInfo>You have modifications that can be published.</AlertInfo>
|
||||||
)}
|
)}
|
||||||
@@ -269,6 +278,7 @@ export const WhatsAppModal = ({ isOpen, onClose }: ModalProps): JSX.Element => {
|
|||||||
|
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<SwitchWithLabel
|
<SwitchWithLabel
|
||||||
|
isDisabled={!hasProPerks(workspace)}
|
||||||
label="Enable WhatsApp integration"
|
label="Enable WhatsApp integration"
|
||||||
initialValue={
|
initialValue={
|
||||||
typebot?.settings.whatsApp?.isEnabled ?? false
|
typebot?.settings.whatsApp?.isEnabled ?? false
|
||||||
|
|||||||
@@ -38,18 +38,11 @@ export const UsageAlertBanners = ({ workspace }: Props) => {
|
|||||||
<>
|
<>
|
||||||
{chatsLimitPercentage > ALERT_CHATS_PERCENT_THRESHOLD && (
|
{chatsLimitPercentage > ALERT_CHATS_PERCENT_THRESHOLD && (
|
||||||
<Flex p="4">
|
<Flex p="4">
|
||||||
<UnlockPlanAlertInfo
|
<UnlockPlanAlertInfo status="warning" buttonLabel="Upgrade">
|
||||||
status="warning"
|
Your workspace collected <strong>{chatsLimitPercentage}%</strong> of
|
||||||
contentLabel={
|
your total chats limit this month. Upgrade your plan to continue
|
||||||
<>
|
chatting with your customers beyond this limit.
|
||||||
Your workspace collected{' '}
|
</UnlockPlanAlertInfo>
|
||||||
<strong>{chatsLimitPercentage}%</strong> of your total chats
|
|
||||||
limit this month. Upgrade your plan to continue chatting with
|
|
||||||
your customers beyond this limit.
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
buttonLabel="Upgrade"
|
|
||||||
/>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -119,12 +119,12 @@ export const updateTypebot = authenticatedProcedure
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typebot.whatsAppCredentialsId &&
|
typebot.settings?.whatsApp?.isEnabled &&
|
||||||
!hasProPerks(existingTypebot.workspace)
|
!hasProPerks(existingTypebot.workspace)
|
||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'WhatsApp is only available for Pro workspaces',
|
message: 'WhatsApp can be enabled only on a Pro workspaces',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,9 @@ export const MembersList = () => {
|
|||||||
return (
|
return (
|
||||||
<Stack w="full" spacing={3}>
|
<Stack w="full" spacing={3}>
|
||||||
{!canInviteNewMember && (
|
{!canInviteNewMember && (
|
||||||
<UnlockPlanAlertInfo contentLabel={scopedT('unlockBanner.label')} />
|
<UnlockPlanAlertInfo>
|
||||||
|
{scopedT('unlockBanner.label')}
|
||||||
|
</UnlockPlanAlertInfo>
|
||||||
)}
|
)}
|
||||||
{isDefined(seatsLimit) && (
|
{isDefined(seatsLimit) && (
|
||||||
<Heading fontSize="2xl">
|
<Heading fontSize="2xl">
|
||||||
|
|||||||
@@ -191,13 +191,18 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
await prisma.typebot.updateMany({
|
await prisma.typebot.updateMany({
|
||||||
where: { id: typebot.id },
|
where: { id: typebot.id },
|
||||||
data: {
|
data: {
|
||||||
whatsAppCredentialsId: null,
|
|
||||||
settings: {
|
settings: {
|
||||||
...settings,
|
...settings,
|
||||||
general: {
|
general: {
|
||||||
...settings.general,
|
...settings.general,
|
||||||
isBrandingEnabled: true,
|
isBrandingEnabled: true,
|
||||||
},
|
},
|
||||||
|
whatsApp: settings.whatsApp
|
||||||
|
? {
|
||||||
|
...settings.whatsApp,
|
||||||
|
isEnabled: false,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user