feat(inputs): ✨ Add buttons input
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { chakra } from '@chakra-ui/system'
|
||||
import { useTypebot } from 'contexts/TypebotContext/TypebotContext'
|
||||
import { ChoiceItem } from 'models'
|
||||
import React, { useMemo } from 'react'
|
||||
import { isDefined } from 'utils'
|
||||
import { isDefined, isSingleChoiceInput } from 'utils'
|
||||
import { DrawingEdge } from './DrawingEdge'
|
||||
import { Edge } from './Edge'
|
||||
|
||||
@ -13,6 +14,18 @@ export const Edges = () => {
|
||||
isDefined(typebot.steps.byId[stepId].target)
|
||||
)
|
||||
}, [typebot])
|
||||
const singleChoiceItemsWithTarget: ChoiceItem[] = useMemo(() => {
|
||||
if (!typebot) return []
|
||||
return typebot.choiceItems.allIds
|
||||
.filter(
|
||||
(itemId) =>
|
||||
isDefined(typebot.choiceItems.byId[itemId].target) &&
|
||||
isSingleChoiceInput(
|
||||
typebot.steps.byId[typebot.choiceItems.byId[itemId].stepId]
|
||||
)
|
||||
)
|
||||
.map((itemId) => typebot.choiceItems.byId[itemId])
|
||||
}, [typebot])
|
||||
|
||||
return (
|
||||
<chakra.svg
|
||||
@ -27,6 +40,9 @@ export const Edges = () => {
|
||||
{stepIdsWithTarget.map((stepId) => (
|
||||
<Edge key={stepId} stepId={stepId} />
|
||||
))}
|
||||
{singleChoiceItemsWithTarget.map((item) => (
|
||||
<Edge key={item.id} stepId={item.stepId} item={item} />
|
||||
))}
|
||||
<marker
|
||||
id={'arrow'}
|
||||
refX="8"
|
||||
|
Reference in New Issue
Block a user