2
0

(api) Add CRUD typebot endpoints

Closes #320, closes #696
This commit is contained in:
Baptiste Arnaud
2023-08-17 09:39:11 +02:00
parent 019f72ac7e
commit 454d320c6b
78 changed files with 25014 additions and 1073 deletions

View File

@@ -7,7 +7,8 @@ export const useAutoSave = <T>(
item,
debounceTimeout,
}: {
handler: () => Promise<void>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handler: () => Promise<any>
item?: T
debounceTimeout: number
},

View File

@@ -1,33 +0,0 @@
import { fetcher } from '@/helpers/fetcher'
import { PublicTypebot, Typebot, Webhook } from '@typebot.io/schemas'
import useSWR from 'swr'
import { env } from '@typebot.io/lib'
export const useTypebotQuery = ({
typebotId,
onError,
}: {
typebotId?: string
onError?: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<
{
typebot: Typebot
webhooks: Webhook[]
publishedTypebot?: PublicTypebot
isReadOnly?: boolean
},
Error
>(typebotId ? `/api/typebots/${typebotId}` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
})
if (error && onError) onError(error)
return {
typebot: data?.typebot,
webhooks: data?.webhooks,
publishedTypebot: data?.publishedTypebot,
isReadOnly: data?.isReadOnly,
isLoading: !error && !data,
mutate,
}
}