Files
bot/apps/builder/src/features/blocks/integrations/webhook/components/WebhookContent.tsx

34 lines
1.0 KiB
TypeScript
Raw Normal View History

import { Stack, Text } from '@chakra-ui/react'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { WebhookBlock } from '@typebot.io/schemas'
import { byId } from '@typebot.io/lib'
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
}
export const WebhookContent = ({ block: { webhookId, options } }: Props) => {
const { typebot } = useTypebot()
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 (
<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
)
}