🐛 Remove publicId and customDomain duplication on imported bots

This commit is contained in:
Baptiste Arnaud
2023-08-17 16:32:37 +02:00
parent 906845bd76
commit 304dfe2dab
17 changed files with 61 additions and 70 deletions

View File

@@ -56,7 +56,13 @@ export const CreateNewTypebotButtons = () => {
mutate({
workspaceId: workspace.id,
typebot: {
...(typebot ? { ...typebot } : {}),
...(typebot
? {
...typebot,
publicId: undefined,
customDomain: undefined,
}
: {}),
folderId,
},
})

View File

@@ -19,13 +19,12 @@ export const ImportTypebotFromFileButton = ({
const file = e.target.files[0]
const fileContent = await readFile(file)
try {
const typebot = parseInvalidTypebot(JSON.parse(fileContent))
typebotSchema
const typebot = typebotSchema
.omit({
createdAt: true,
updatedAt: true,
})
.parse(typebot)
.parse(parseInvalidTypebot(JSON.parse(fileContent)))
onNewTypebot(typebot as Typebot)
} catch (err) {
console.error(err)