2
0

fix(editor): 🚑️ Step id duplication

This commit is contained in:
Baptiste Arnaud
2022-03-24 09:44:04 +01:00
parent e502413ecf
commit b8019f3732
2 changed files with 18 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import {
Block,
DraggableStep,
DraggableStepType,
IntegrationStepType,
StepIndices,
Typebot,
} from 'models'
@ -65,7 +66,11 @@ const blocksActions = (setTypebot: SetTypebot): BlocksActions => ({
...block,
title: `${block.title} copy`,
id,
steps: block.steps.map((s) => ({ ...s, blockId: id })),
steps: block.steps.map((s) =>
s.type === IntegrationStepType.WEBHOOK
? { ...s, blockId: id, id: cuid(), webhookId: cuid() }
: { ...s, blockId: id, id: cuid() }
),
graphCoordinates: {
x: block.graphCoordinates.x + 200,
y: block.graphCoordinates.y + 100,

View File

@ -4,6 +4,7 @@ import {
DraggableStep,
DraggableStepType,
StepIndices,
IntegrationStepType,
} from 'models'
import { parseNewStep } from 'services/typebots/typebots'
import { removeEmptyBlocks } from './blocks'
@ -54,7 +55,14 @@ const stepsAction = (setTypebot: SetTypebot): StepsActions => ({
produce(typebot, (typebot) => {
const step = typebot.blocks[blockIndex].steps[stepIndex]
const id = cuid()
const newStep: Step = {
const newStep: Step =
step.type === IntegrationStepType.WEBHOOK
? {
...step,
id,
webhookId: cuid(),
}
: {
...step,
id,
}