import { Flex, Heading, HStack, IconButton, Stack, Tag, useToast, Wrap, Text, } from '@chakra-ui/react' import { TrashIcon } from 'assets/icons' import { UpgradeButton } from 'components/shared/buttons/UpgradeButton' import { useTypebot } from 'contexts/TypebotContext/TypebotContext' import { useWorkspace } from 'contexts/WorkspaceContext' import React from 'react' import { parseDefaultPublicId } from 'services/typebots' import { isFreePlan } from 'services/workspace' import { isDefined, isNotDefined } from 'utils' import { CustomDomainsDropdown } from './customDomain/CustomDomainsDropdown' import { EditableUrl } from './EditableUrl' import { integrationsList } from './integrations/EmbedButton' export const ShareContent = () => { const { workspace } = useWorkspace() const { typebot, updateOnBothTypebots } = useTypebot() const toast = useToast({ position: 'top-right', status: 'error', }) const handlePublicIdChange = (publicId: string) => { if (publicId === typebot?.publicId) return if (publicId.length < 4) return toast({ description: 'ID must be longer than 4 characters' }) updateOnBothTypebots({ publicId }) } const publicId = typebot ? typebot?.publicId ?? parseDefaultPublicId(typebot.name, typebot.id) : '' const isPublished = isDefined(typebot?.publishedTypebotId) const handlePathnameChange = (pathname: string) => { if (!typebot?.customDomain) return const existingHost = typebot.customDomain?.split('/')[0] const newDomain = pathname === '' ? existingHost : existingHost + '/' + pathname handleCustomDomainChange(newDomain) } const handleCustomDomainChange = (customDomain: string | null) => updateOnBothTypebots({ customDomain }) return ( Your typebot link {typebot && ( )} {typebot?.customDomain && ( } aria-label="Remove custom domain" size="xs" onClick={() => handleCustomDomainChange(null)} /> )} {isFreePlan(workspace) ? ( Add my domain{' '} Pro ) : ( <> {isNotDefined(typebot?.customDomain) && ( )} )} Embed your typebot {integrationsList.map((IntegrationButton, idx) => ( ))} ) }