♿ Remember last typebot viewed for support bubble
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||
import { useUser } from '@/features/account/hooks/useUser'
|
||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
||||
import React from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Bubble, BubbleProps } from '@typebot.io/nextjs'
|
||||
import { planToReadable } from '@/features/billing/helpers/planToReadable'
|
||||
|
||||
@ -10,6 +10,14 @@ export const SupportBubble = (props: Omit<BubbleProps, 'typebot'>) => {
|
||||
const { user } = useUser()
|
||||
const { workspace } = useWorkspace()
|
||||
|
||||
const [lastViewedTypebotId, setLastViewedTypebotId] = useState(typebot?.id)
|
||||
|
||||
useEffect(() => {
|
||||
if (!typebot?.id) return
|
||||
if (lastViewedTypebotId === typebot?.id) return
|
||||
setLastViewedTypebotId(typebot?.id)
|
||||
}, [lastViewedTypebotId, typebot?.id])
|
||||
|
||||
return (
|
||||
<Bubble
|
||||
apiHost="https://viewer.typebot.io"
|
||||
@ -18,7 +26,7 @@ export const SupportBubble = (props: Omit<BubbleProps, 'typebot'>) => {
|
||||
'User ID': user?.id,
|
||||
'First name': user?.name?.split(' ')[0] ?? undefined,
|
||||
Email: user?.email ?? undefined,
|
||||
'Typebot ID': typebot?.id,
|
||||
'Typebot ID': lastViewedTypebotId,
|
||||
'Avatar URL': user?.image ?? undefined,
|
||||
Plan: planToReadable(workspace?.plan),
|
||||
}}
|
||||
|
Reference in New Issue
Block a user