🚸 (editor) Improve typebot updatedAt detection
Make sure the database is the single source of truth
This commit is contained in:
@ -169,7 +169,11 @@ export const TypebotProvider = ({
|
||||
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
|
||||
return
|
||||
setIsSavingLoading(true)
|
||||
const { error } = await updateTypebotQuery(typebotToSave.id, typebotToSave)
|
||||
const { data, error } = await updateTypebotQuery(
|
||||
typebotToSave.id,
|
||||
typebotToSave
|
||||
)
|
||||
if (data?.typebot) setLocalTypebot({ ...data.typebot })
|
||||
setIsSavingLoading(false)
|
||||
if (error) {
|
||||
showToast({ title: error.name, description: error.message })
|
||||
|
@ -2,7 +2,7 @@ import { Typebot } from 'models'
|
||||
import { sendRequest } from 'utils'
|
||||
|
||||
export const updateTypebotQuery = async (id: string, typebot: Typebot) =>
|
||||
sendRequest({
|
||||
sendRequest<{ typebot: Typebot }>({
|
||||
url: `/api/typebots/${id}`,
|
||||
method: 'PUT',
|
||||
body: typebot,
|
||||
|
@ -5,7 +5,7 @@ export const patchTypebotQuery = async (
|
||||
id: string,
|
||||
typebot: Partial<Typebot>
|
||||
) =>
|
||||
sendRequest({
|
||||
sendRequest<{ typebot: Typebot }>({
|
||||
url: `/api/typebots/${id}`,
|
||||
method: 'PATCH',
|
||||
body: typebot,
|
||||
|
Reference in New Issue
Block a user