♻️ (editor) Improve webhook creation

Remove terrible useEffects
This commit is contained in:
Baptiste Arnaud
2023-02-15 14:51:58 +01:00
parent 6e066c44e1
commit ac464eabdf
23 changed files with 481 additions and 528 deletions

View File

@@ -1,4 +1,4 @@
import { duplicateWebhookQueries } from '@/features/blocks/integrations/webhook'
import { duplicateWebhookQuery } from '@/features/blocks/integrations/webhook'
import { createId } from '@paralleldrive/cuid2'
import { Plan, Prisma } from 'db'
import {
@@ -25,11 +25,13 @@ export const importTypebotQuery = async (typebot: Typebot, userPlan: Plan) => {
.filter(isWebhookBlock)
await Promise.all(
webhookBlocks.map((s) =>
duplicateWebhookQueries(
newTypebot.id,
s.webhookId,
webhookIdsMapping.get(s.webhookId) as string
)
duplicateWebhookQuery({
existingIds: { typebotId: typebot.id, webhookId: s.webhookId },
newIds: {
typebotId: newTypebot.id,
webhookId: webhookIdsMapping.get(s.webhookId) as string,
},
})
)
)
return { data, error }