2023-03-09 08:46:36 +01:00
|
|
|
import { BlockIndices, ChoiceInputBlock } from 'models'
|
2023-02-23 14:44:37 +01:00
|
|
|
import React from 'react'
|
|
|
|
|
import { ItemNodesList } from '@/features/graph/components/Nodes/ItemNode'
|
2023-03-09 08:46:36 +01:00
|
|
|
import { Stack, Tag, Text, Wrap } from '@chakra-ui/react'
|
2023-02-23 14:44:37 +01:00
|
|
|
import { useTypebot } from '@/features/editor'
|
2023-03-09 08:46:36 +01:00
|
|
|
import { SetVariableLabel } from '@/components/SetVariableLabel'
|
2023-02-23 14:44:37 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
block: ChoiceInputBlock
|
|
|
|
|
indices: BlockIndices
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ButtonsBlockNode = ({ block, indices }: Props) => {
|
|
|
|
|
const { typebot } = useTypebot()
|
|
|
|
|
const dynamicVariableName = typebot?.variables.find(
|
|
|
|
|
(variable) => variable.id === block.options.dynamicVariableId
|
|
|
|
|
)?.name
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Stack w="full">
|
|
|
|
|
{block.options.dynamicVariableId ? (
|
|
|
|
|
<Wrap spacing={1}>
|
|
|
|
|
<Text>Display</Text>
|
|
|
|
|
<Tag bg="orange.400" color="white">
|
|
|
|
|
{dynamicVariableName}
|
|
|
|
|
</Tag>
|
|
|
|
|
<Text>buttons</Text>
|
|
|
|
|
</Wrap>
|
|
|
|
|
) : (
|
|
|
|
|
<ItemNodesList block={block} indices={indices} />
|
|
|
|
|
)}
|
2023-03-09 17:37:39 +01:00
|
|
|
{block.options.variableId ? (
|
|
|
|
|
<SetVariableLabel
|
|
|
|
|
variableId={block.options.variableId}
|
|
|
|
|
variables={typebot?.variables}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
2023-02-23 14:44:37 +01:00
|
|
|
</Stack>
|
|
|
|
|
)
|
|
|
|
|
}
|