2
0
Files
bot/apps/builder/components/shared/SupportBubble.tsx

47 lines
1.2 KiB
TypeScript
Raw Normal View History

import { useTypebot } from 'contexts/TypebotContext'
import { useUser } from 'contexts/UserContext'
2022-03-05 09:07:44 +01:00
import { Plan } from 'db'
2022-02-14 11:33:38 +01:00
import React, { useEffect } from 'react'
import { isCloudProdInstance } from 'services/utils'
2022-02-14 11:33:38 +01:00
import { initBubble } from 'typebot-js'
export const SupportBubble = () => {
const { typebot } = useTypebot()
const { user } = useUser()
2022-02-14 11:33:38 +01:00
useEffect(() => {
if (isCloudProdInstance())
initBubble({
publishId: 'typebot-support',
viewerHost: process.env.NEXT_PUBLIC_VIEWER_URL,
backgroundColor: '#ffffff',
button: { color: '#0042DA' },
hiddenVariables: {
'User ID': user?.id,
Name: user?.name ?? undefined,
Email: user?.email ?? undefined,
'Typebot ID': typebot?.id,
'Avatar URL': user?.image ?? undefined,
Plan: planToReadable(user?.plan),
},
})
2022-02-14 11:33:38 +01:00
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, typebot])
2022-02-14 11:33:38 +01:00
return <></>
}
2022-03-05 09:07:44 +01:00
const planToReadable = (plan?: Plan) => {
if (!plan) return
switch (plan) {
case 'FREE':
return 'Free'
case 'LIFETIME':
return 'Lifetime'
case 'OFFERED':
return 'Offered'
case 'PRO':
return 'Pro'
}
}