2023-03-09 17:37:39 +01:00
|
|
|
import { Stack, Text } from '@chakra-ui/react'
|
2022-11-15 09:35:48 +01:00
|
|
|
import { useTypebot } from '@/features/editor'
|
2022-06-11 07:27:38 +02:00
|
|
|
import { WebhookBlock } from 'models'
|
2022-03-01 07:13:09 +01:00
|
|
|
import { byId } from 'utils'
|
2023-03-09 17:37:39 +01:00
|
|
|
import { SetVariableLabel } from '@/components/SetVariableLabel'
|
2022-01-22 18:24:57 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
2022-06-11 07:27:38 +02:00
|
|
|
block: WebhookBlock
|
2022-01-22 18:24:57 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-09 17:37:39 +01:00
|
|
|
export const WebhookContent = ({ block: { webhookId, options } }: Props) => {
|
|
|
|
|
const { typebot } = useTypebot()
|
2022-03-01 07:13:09 +01:00
|
|
|
const { webhooks } = useTypebot()
|
|
|
|
|
const webhook = webhooks.find(byId(webhookId))
|
|
|
|
|
|
2022-01-22 18:24:57 +01:00
|
|
|
if (!webhook?.url) return <Text color="gray.500">Configure...</Text>
|
|
|
|
|
return (
|
2023-03-09 17:37:39 +01:00
|
|
|
<Stack w="full">
|
|
|
|
|
<Text noOfLines={2} pr="6">
|
|
|
|
|
{webhook.method} {webhook.url}
|
|
|
|
|
</Text>
|
|
|
|
|
{options.responseVariableMapping
|
|
|
|
|
.filter((mapping) => mapping.variableId)
|
|
|
|
|
.map((mapping) => (
|
|
|
|
|
<SetVariableLabel
|
|
|
|
|
key={mapping.variableId}
|
|
|
|
|
variableId={mapping.variableId as string}
|
|
|
|
|
variables={typebot?.variables}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Stack>
|
2022-01-22 18:24:57 +01:00
|
|
|
)
|
|
|
|
|
}
|