fix: 🐛 Duplicate webhook id
This commit is contained in:
@@ -41,6 +41,7 @@ import useSWR from 'swr'
|
|||||||
import { fetcher, toKebabCase } from '../utils'
|
import { fetcher, toKebabCase } from '../utils'
|
||||||
import {
|
import {
|
||||||
isBubbleStepType,
|
isBubbleStepType,
|
||||||
|
isWebhookStep,
|
||||||
stepTypeHasItems,
|
stepTypeHasItems,
|
||||||
stepTypeHasOption,
|
stepTypeHasOption,
|
||||||
stepTypeHasWebhook,
|
stepTypeHasWebhook,
|
||||||
@@ -108,7 +109,7 @@ export const importTypebot = async (typebot: Typebot) => {
|
|||||||
return sendRequest<Typebot>({
|
return sendRequest<Typebot>({
|
||||||
url: `/api/typebots`,
|
url: `/api/typebots`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: typebotToImport,
|
body: cleanUpTypebot(typebotToImport),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,10 +133,22 @@ export const duplicateTypebot = async (typebotId: string) => {
|
|||||||
return sendRequest<Typebot>({
|
return sendRequest<Typebot>({
|
||||||
url: `/api/typebots`,
|
url: `/api/typebots`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: duplicatedTypebot,
|
body: cleanUpTypebot(duplicatedTypebot),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cleanUpTypebot = (
|
||||||
|
typebot: Omit<Typebot, 'id' | 'updatedAt' | 'createdAt'>
|
||||||
|
) => ({
|
||||||
|
...typebot,
|
||||||
|
blocks: typebot.blocks.map((b) => ({
|
||||||
|
...b,
|
||||||
|
steps: b.steps.map((s) =>
|
||||||
|
isWebhookStep(s) ? { ...s, webhookId: cuid() } : s
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
|
||||||
const getTypebot = (typebotId: string) =>
|
const getTypebot = (typebotId: string) =>
|
||||||
sendRequest<{ typebot: Typebot }>({
|
sendRequest<{ typebot: Typebot }>({
|
||||||
url: `/api/typebots/${typebotId}`,
|
url: `/api/typebots/${typebotId}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user