♻️ (builder) Change to features-centric folder structure

This commit is contained in:
Baptiste Arnaud
2022-11-15 09:35:48 +01:00
committed by Baptiste Arnaud
parent 3686465a85
commit 643571fe7d
683 changed files with 3907 additions and 3643 deletions

View File

@@ -0,0 +1,43 @@
import { useTypebot } from '@/features/editor'
import { useUser } from '@/features/account'
import { useWorkspace } from '@/features/workspace'
import React, { useEffect, useState } from 'react'
import { initBubble } from 'typebot-js'
import { isCloudProdInstance } from '@/utils/helpers'
import { planToReadable } from '@/features/billing'
export const SupportBubble = () => {
const { typebot } = useTypebot()
const { user } = useUser()
const { workspace } = useWorkspace()
const [localTypebotId, setLocalTypebotId] = useState(typebot?.id)
const [localUserId, setLocalUserId] = useState(user?.id)
useEffect(() => {
if (
isCloudProdInstance() &&
(localTypebotId !== typebot?.id || localUserId !== user?.id)
) {
setLocalTypebotId(typebot?.id)
setLocalUserId(user?.id)
initBubble({
url: `https://viewer.typebot.io/typebot-support`,
backgroundColor: '#ffffff',
button: {
color: '#0042DA',
},
hiddenVariables: {
'User ID': user?.id,
'First name': user?.name?.split(' ')[0] ?? undefined,
Email: user?.email ?? undefined,
'Typebot ID': typebot?.id,
'Avatar URL': user?.image ?? undefined,
Plan: planToReadable(workspace?.plan),
},
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, typebot])
return <></>
}