2
0

fix(editor): 🐛 subscribe unsub zapier

This commit is contained in:
Baptiste Arnaud
2022-03-01 07:55:20 +01:00
parent dc510100e5
commit 4630512b8b
3 changed files with 24 additions and 5 deletions

View File

@ -20,6 +20,7 @@ type Props = {
export const ZapierSettings = ({ step }: Props) => {
const { webhooks } = useTypebot()
const webhook = webhooks.find(byId(step.webhookId))
return (
<Stack spacing={4}>
<Alert

View File

@ -1,15 +1,30 @@
import { Text } from '@chakra-ui/react'
import { useTypebot } from 'contexts/TypebotContext'
import { ZapierStep } from 'models'
import { defaultWebhookAttributes, Webhook, ZapierStep } from 'models'
import { useEffect } from 'react'
import { byId, isNotDefined } from 'utils'
type Props = {
step: ZapierStep
}
export const ZapierContent = ({ step: { webhookId } }: Props) => {
const { webhooks } = useTypebot()
const webhook = webhooks.find(byId(webhookId))
export const ZapierContent = ({ step }: Props) => {
const { webhooks, typebot, updateWebhook } = useTypebot()
const webhook = webhooks.find(byId(step.webhookId))
useEffect(() => {
if (!typebot) return
if (!webhook) {
const { webhookId } = step
const newWebhook = {
id: webhookId,
...defaultWebhookAttributes,
typebotId: typebot.id,
} as Webhook
updateWebhook(webhookId, newWebhook)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
if (isNotDefined(webhook?.body))
return <Text color="gray.500">Configure...</Text>