2023-03-03 15:03:31 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { Tag, Text } from '@chakra-ui/react'
|
2023-03-15 11:51:30 +01:00
|
|
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
2023-10-27 09:23:50 +02:00
|
|
|
import { byId, isDefined } from '@typebot.io/lib'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { JumpBlock } from '@typebot.io/schemas/features/blocks/logic/jump'
|
2023-03-03 15:03:31 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
options: JumpBlock['options']
|
|
|
|
}
|
|
|
|
|
|
|
|
export const JumpNodeBody = ({ options }: Props) => {
|
|
|
|
const { typebot } = useTypebot()
|
|
|
|
const selectedGroup = typebot?.groups.find(byId(options.groupId))
|
|
|
|
const blockIndex = selectedGroup?.blocks.findIndex(byId(options.blockId))
|
|
|
|
if (!selectedGroup) return <Text color="gray.500">Configure...</Text>
|
|
|
|
return (
|
|
|
|
<Text>
|
2023-10-27 09:23:50 +02:00
|
|
|
Jump to <Tag colorScheme="blue">{selectedGroup.title}</Tag>{' '}
|
2023-03-03 15:03:31 +01:00
|
|
|
{isDefined(blockIndex) && blockIndex >= 0 ? (
|
|
|
|
<>
|
|
|
|
at block <Tag colorScheme="blue">{blockIndex + 1}</Tag>
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
</Text>
|
|
|
|
)
|
|
|
|
}
|