🚸 Rename "webhook" block to "HTTP request"
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Alert, AlertIcon, Button, Link, Stack, Text } from '@chakra-ui/react'
|
||||
import { ExternalLinkIcon } from '@/components/icons'
|
||||
import { MakeComBlock, Webhook } from '@typebot.io/schemas'
|
||||
import { MakeComBlock, HttpRequest } from '@typebot.io/schemas'
|
||||
import React from 'react'
|
||||
import { WebhookAdvancedConfigForm } from '../../webhook/components/WebhookAdvancedConfigForm'
|
||||
import { HttpRequestAdvancedConfigForm } from '../../webhook/components/HttpRequestAdvancedConfigForm'
|
||||
|
||||
type Props = {
|
||||
block: MakeComBlock
|
||||
@@ -13,7 +13,7 @@ export const MakeComSettings = ({
|
||||
block: { id: blockId, options },
|
||||
onOptionsChange,
|
||||
}: Props) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: Webhook) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: HttpRequest) => {
|
||||
onOptionsChange({
|
||||
...options,
|
||||
webhook: newLocalWebhook,
|
||||
@@ -42,7 +42,7 @@ export const MakeComSettings = ({
|
||||
</Stack>
|
||||
)}
|
||||
</Alert>
|
||||
<WebhookAdvancedConfigForm
|
||||
<HttpRequestAdvancedConfigForm
|
||||
blockId={blockId}
|
||||
webhook={options?.webhook}
|
||||
options={options}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Alert, AlertIcon, Button, Link, Stack, Text } from '@chakra-ui/react'
|
||||
import { ExternalLinkIcon } from '@/components/icons'
|
||||
import { PabblyConnectBlock, Webhook } from '@typebot.io/schemas'
|
||||
import { PabblyConnectBlock, HttpRequest } from '@typebot.io/schemas'
|
||||
import React from 'react'
|
||||
import { WebhookAdvancedConfigForm } from '../../webhook/components/WebhookAdvancedConfigForm'
|
||||
import { HttpRequestAdvancedConfigForm } from '../../webhook/components/HttpRequestAdvancedConfigForm'
|
||||
import { TextInput } from '@/components/inputs'
|
||||
|
||||
type Props = {
|
||||
@@ -14,7 +14,7 @@ export const PabblyConnectSettings = ({
|
||||
block: { id: blockId, options },
|
||||
onOptionsChange,
|
||||
}: Props) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: Webhook) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: HttpRequest) => {
|
||||
onOptionsChange({
|
||||
...options,
|
||||
webhook: newLocalWebhook,
|
||||
@@ -54,7 +54,7 @@ export const PabblyConnectSettings = ({
|
||||
withVariableButton={false}
|
||||
debounceTimeout={0}
|
||||
/>
|
||||
<WebhookAdvancedConfigForm
|
||||
<HttpRequestAdvancedConfigForm
|
||||
blockId={blockId}
|
||||
webhook={options?.webhook}
|
||||
options={options}
|
||||
|
||||
@@ -2,7 +2,7 @@ import prisma from '@typebot.io/lib/prisma'
|
||||
import { canWriteTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Block, WebhookBlock, parseGroups } from '@typebot.io/schemas'
|
||||
import { Block, HttpRequestBlock, parseGroups } from '@typebot.io/schemas'
|
||||
import { byId, isWebhookBlock } from '@typebot.io/lib'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -47,7 +47,7 @@ export const subscribeWebhook = authenticatedProcedure
|
||||
|
||||
const webhookBlock = groups
|
||||
.flatMap<Block>((g) => g.blocks)
|
||||
.find(byId(blockId)) as WebhookBlock | null
|
||||
.find(byId(blockId)) as HttpRequestBlock | null
|
||||
|
||||
if (!webhookBlock || !isWebhookBlock(webhookBlock))
|
||||
throw new TRPCError({
|
||||
|
||||
@@ -2,7 +2,7 @@ import prisma from '@typebot.io/lib/prisma'
|
||||
import { canWriteTypebots } from '@/helpers/databaseRules'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Block, WebhookBlock, parseGroups } from '@typebot.io/schemas'
|
||||
import { Block, HttpRequestBlock, parseGroups } from '@typebot.io/schemas'
|
||||
import { byId, isWebhookBlock } from '@typebot.io/lib'
|
||||
import { z } from 'zod'
|
||||
|
||||
@@ -46,7 +46,7 @@ export const unsubscribeWebhook = authenticatedProcedure
|
||||
|
||||
const webhookBlock = groups
|
||||
.flatMap<Block>((g) => g.blocks)
|
||||
.find(byId(blockId)) as WebhookBlock | null
|
||||
.find(byId(blockId)) as HttpRequestBlock | null
|
||||
|
||||
if (!webhookBlock || !isWebhookBlock(webhookBlock))
|
||||
throw new TRPCError({
|
||||
|
||||
@@ -19,8 +19,8 @@ import {
|
||||
KeyValue,
|
||||
VariableForTest,
|
||||
ResponseVariableMapping,
|
||||
Webhook,
|
||||
WebhookBlock,
|
||||
HttpRequest,
|
||||
HttpRequestBlock,
|
||||
} from '@typebot.io/schemas'
|
||||
import { useState, useMemo } from 'react'
|
||||
import { executeWebhook } from '../queries/executeWebhookQuery'
|
||||
@@ -41,13 +41,13 @@ import { NumberInput } from '@/components/inputs'
|
||||
|
||||
type Props = {
|
||||
blockId: string
|
||||
webhook: Webhook | undefined
|
||||
options: WebhookBlock['options']
|
||||
onWebhookChange: (webhook: Webhook) => void
|
||||
onOptionsChange: (options: WebhookBlock['options']) => void
|
||||
webhook: HttpRequest | undefined
|
||||
options: HttpRequestBlock['options']
|
||||
onWebhookChange: (webhook: HttpRequest) => void
|
||||
onOptionsChange: (options: HttpRequestBlock['options']) => void
|
||||
}
|
||||
|
||||
export const WebhookAdvancedConfigForm = ({
|
||||
export const HttpRequestAdvancedConfigForm = ({
|
||||
blockId,
|
||||
webhook,
|
||||
options,
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Stack, Text } from '@chakra-ui/react'
|
||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||
import { WebhookBlock } from '@typebot.io/schemas'
|
||||
import { HttpRequestBlock } from '@typebot.io/schemas'
|
||||
import { SetVariableLabel } from '@/components/SetVariableLabel'
|
||||
|
||||
type Props = {
|
||||
block: WebhookBlock
|
||||
block: HttpRequestBlock
|
||||
}
|
||||
|
||||
export const WebhookContent = ({ block: { options } }: Props) => {
|
||||
@@ -0,0 +1,5 @@
|
||||
import { WebhookIcon } from '@/components/icons'
|
||||
import { IconProps } from '@chakra-ui/react'
|
||||
import React from 'react'
|
||||
|
||||
export const HttpRequestIcon = (props: IconProps) => <WebhookIcon {...props} />
|
||||
@@ -1,19 +1,19 @@
|
||||
import React from 'react'
|
||||
import { Stack } from '@chakra-ui/react'
|
||||
import { Webhook, WebhookBlock } from '@typebot.io/schemas'
|
||||
import { HttpRequest, HttpRequestBlock } from '@typebot.io/schemas'
|
||||
import { TextInput } from '@/components/inputs'
|
||||
import { WebhookAdvancedConfigForm } from './WebhookAdvancedConfigForm'
|
||||
import { HttpRequestAdvancedConfigForm } from './HttpRequestAdvancedConfigForm'
|
||||
|
||||
type Props = {
|
||||
block: WebhookBlock
|
||||
onOptionsChange: (options: WebhookBlock['options']) => void
|
||||
block: HttpRequestBlock
|
||||
onOptionsChange: (options: HttpRequestBlock['options']) => void
|
||||
}
|
||||
|
||||
export const WebhookSettings = ({
|
||||
export const HttpRequestSettings = ({
|
||||
block: { id: blockId, options },
|
||||
onOptionsChange,
|
||||
}: Props) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: Webhook) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: HttpRequest) => {
|
||||
onOptionsChange({ ...options, webhook: newLocalWebhook })
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ export const WebhookSettings = ({
|
||||
return (
|
||||
<Stack spacing={4}>
|
||||
<TextInput
|
||||
placeholder="Paste webhook URL..."
|
||||
placeholder="Paste URL..."
|
||||
defaultValue={options?.webhook?.url}
|
||||
onChange={updateUrl}
|
||||
/>
|
||||
<WebhookAdvancedConfigForm
|
||||
<HttpRequestAdvancedConfigForm
|
||||
blockId={blockId}
|
||||
webhook={options?.webhook}
|
||||
options={options}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { WebhookIcon as WebhookIco } from '@/components/icons'
|
||||
import { IconProps } from '@chakra-ui/react'
|
||||
import React from 'react'
|
||||
|
||||
export const WebhookIcon = (props: IconProps) => <WebhookIco {...props} />
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Variable, WebhookResponse } from '@typebot.io/schemas'
|
||||
import { Variable, HttpResponse } from '@typebot.io/schemas'
|
||||
import { sendRequest } from '@typebot.io/lib'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
@@ -7,7 +7,7 @@ export const executeWebhook = (
|
||||
variables: Variable[],
|
||||
{ blockId }: { blockId: string }
|
||||
) =>
|
||||
sendRequest<WebhookResponse>({
|
||||
sendRequest<HttpResponse>({
|
||||
url: `${env.NEXT_PUBLIC_VIEWER_URL[0]}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
|
||||
method: 'POST',
|
||||
body: {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { Alert, AlertIcon, Button, Link, Stack, Text } from '@chakra-ui/react'
|
||||
import { ExternalLinkIcon } from '@/components/icons'
|
||||
import { Webhook, WebhookBlock, ZapierBlock } from '@typebot.io/schemas'
|
||||
import { HttpRequest, HttpRequestBlock, ZapierBlock } from '@typebot.io/schemas'
|
||||
import React from 'react'
|
||||
import { WebhookAdvancedConfigForm } from '../../webhook/components/WebhookAdvancedConfigForm'
|
||||
import { HttpRequestAdvancedConfigForm } from '../../webhook/components/HttpRequestAdvancedConfigForm'
|
||||
|
||||
type Props = {
|
||||
block: ZapierBlock
|
||||
onOptionsChange: (options: WebhookBlock['options']) => void
|
||||
onOptionsChange: (options: HttpRequestBlock['options']) => void
|
||||
}
|
||||
|
||||
export const ZapierSettings = ({
|
||||
block: { id: blockId, options },
|
||||
onOptionsChange,
|
||||
}: Props) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: Webhook) => {
|
||||
const setLocalWebhook = async (newLocalWebhook: HttpRequest) => {
|
||||
onOptionsChange({
|
||||
...options,
|
||||
webhook: newLocalWebhook,
|
||||
@@ -43,7 +43,7 @@ export const ZapierSettings = ({
|
||||
</Stack>
|
||||
)}
|
||||
</Alert>
|
||||
<WebhookAdvancedConfigForm
|
||||
<HttpRequestAdvancedConfigForm
|
||||
blockId={blockId}
|
||||
webhook={options?.webhook}
|
||||
options={options}
|
||||
|
||||
Reference in New Issue
Block a user