2
0

feat(api): Add routes for subscribing webhook

This commit is contained in:
Baptiste Arnaud
2022-02-21 11:46:56 +01:00
parent 5a80774ff5
commit 68ae69f366
21 changed files with 470 additions and 175 deletions

View File

@ -12,10 +12,13 @@ import {
Wrap,
} from '@chakra-ui/react'
import { useTypebotDnd } from 'contexts/TypebotDndContext'
import { Typebot } from 'models'
import React, { useEffect, useState } from 'react'
import { createFolder, useFolders } from 'services/folders'
import { patchTypebot, useTypebots } from 'services/typebots'
import {
patchTypebot,
TypebotInDashboard,
useTypebots,
} from 'services/typebots'
import { AnnoucementModal } from './annoucements/AnnoucementModal'
import { BackButton } from './FolderContent/BackButton'
import { CreateBotButton } from './FolderContent/CreateBotButton'
@ -42,7 +45,8 @@ export const FolderContent = ({ folder }: Props) => {
x: 0,
y: 0,
})
const [typebotDragCandidate, setTypebotDragCandidate] = useState<Typebot>()
const [typebotDragCandidate, setTypebotDragCandidate] =
useState<TypebotInDashboard>()
const { isOpen, onOpen, onClose } = useDisclosure()
const toast = useToast({
@ -130,16 +134,17 @@ export const FolderContent = ({ folder }: Props) => {
}
useEventListener('mouseup', handleMouseUp)
const handleMouseDown = (typebot: Typebot) => (e: React.MouseEvent) => {
const element = e.currentTarget as HTMLDivElement
const rect = element.getBoundingClientRect()
setDraggablePosition({ x: rect.left, y: rect.top })
const x = e.clientX - rect.left
const y = e.clientY - rect.top
setRelativeDraggablePosition({ x, y })
setMouseDownPosition({ x: e.screenX, y: e.screenY })
setTypebotDragCandidate(typebot)
}
const handleMouseDown =
(typebot: TypebotInDashboard) => (e: React.MouseEvent) => {
const element = e.currentTarget as HTMLDivElement
const rect = element.getBoundingClientRect()
setDraggablePosition({ x: rect.left, y: rect.top })
const x = e.clientX - rect.left
const y = e.clientY - rect.top
setRelativeDraggablePosition({ x, y })
setMouseDownPosition({ x: e.screenX, y: e.screenY })
setTypebotDragCandidate(typebot)
}
const handleMouseMove = (e: MouseEvent) => {
if (!typebotDragCandidate) return

View File

@ -21,7 +21,7 @@ import { useTypebotDnd } from 'contexts/TypebotDndContext'
import { useDebounce } from 'use-debounce'
type ChatbotCardProps = {
typebot: Typebot
typebot: Pick<Typebot, 'id' | 'publishedTypebotId' | 'name'>
onTypebotDeleted: () => void
onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => void
}
@ -66,7 +66,7 @@ export const TypebotButton = ({
const handleDuplicateClick = async (e: React.MouseEvent) => {
e.stopPropagation()
const { data: createdTypebot, error } = await duplicateTypebot(typebot)
const { data: createdTypebot, error } = await duplicateTypebot(typebot.id)
if (error)
return toast({
title: "Couldn't duplicate typebot",

View File

@ -1,9 +1,9 @@
import { Box, BoxProps, Flex, Text, VStack } from '@chakra-ui/react'
import { GlobeIcon, ToolIcon } from 'assets/icons'
import { Typebot } from 'models'
import { TypebotInDashboard } from 'services/typebots'
type Props = {
typebot: Typebot
typebot: TypebotInDashboard
} & BoxProps
export const TypebotCardOverlay = ({ typebot, ...props }: Props) => {