2
0

feat(db): 🗃️ Remove duplicate fields in PublicTypebot

This commit is contained in:
Baptiste Arnaud
2022-06-04 11:05:46 +02:00
parent 8ec117aee4
commit ad32ae02ef
11 changed files with 29 additions and 47 deletions

View File

@ -52,6 +52,7 @@ type UpdateTypebotPayload = Partial<{
name: string
publishedTypebotId: string
icon: string
customDomain: string
}>
export type SetTypebot = (
@ -77,11 +78,6 @@ const typebotContext = createContext<
webhook: Partial<Webhook>
) => Promise<void>
updateTypebot: (updates: UpdateTypebotPayload) => void
updateOnBothTypebots: (updates: {
publicId?: string
name?: string
customDomain?: string | null
}) => void
publishTypebot: () => void
restorePublishedTypebot: () => void
} & BlocksActions &
@ -322,20 +318,6 @@ export const TypebotContext = ({
}
}
const updateOnBothTypebots = async (updates: {
publicId?: string
name?: string
customDomain?: string | null
}) => {
updateLocalTypebot(updates)
await saveTypebot()
if (!publishedTypebot) return
await savePublishedTypebot({
...publishedTypebot,
...updates,
})
}
const restorePublishedTypebot = () => {
if (!publishedTypebot || !localTypebot) return
setLocalTypebot(parsePublicTypebotToTypebot(publishedTypebot, localTypebot))
@ -377,7 +359,6 @@ export const TypebotContext = ({
isPublished,
updateTypebot: updateLocalTypebot,
restorePublishedTypebot,
updateOnBothTypebots,
updateWebhook,
...blocksActions(setLocalTypebot as SetTypebot),
...stepsAction(setLocalTypebot as SetTypebot),