2
0

🚸 (dashboard) Soften imported bot model check

This commit is contained in:
Baptiste Arnaud
2023-01-16 17:22:34 +01:00
parent ef9170dcb6
commit 67ee197d9b
2 changed files with 5 additions and 7 deletions

View File

@@ -1,8 +1,9 @@
import { useToast } from '@/hooks/useToast' import { useToast } from '@/hooks/useToast'
import { readFile } from '@/utils/helpers' import { readFile } from '@/utils/helpers'
import { Button, ButtonProps, chakra } from '@chakra-ui/react' import { Button, ButtonProps, chakra } from '@chakra-ui/react'
import { Typebot, typebotSchema } from 'models' import { groupSchema, Typebot } from 'models'
import React, { ChangeEvent } from 'react' import React, { ChangeEvent } from 'react'
import { z } from 'zod'
type Props = { type Props = {
onNewTypebot: (typebot: Typebot) => void onNewTypebot: (typebot: Typebot) => void
@@ -20,11 +21,7 @@ export const ImportTypebotFromFileButton = ({
const fileContent = await readFile(file) const fileContent = await readFile(file)
try { try {
const typebot = JSON.parse(fileContent) const typebot = JSON.parse(fileContent)
typebotSchema.parse({ z.array(groupSchema).parse(typebot.groups)
...typebot,
createdAt: new Date(),
updatedAt: new Date(),
})
onNewTypebot(typebot) onNewTypebot(typebot)
} catch (err) { } catch (err) {
console.error(err) console.error(err)

View File

@@ -3146,7 +3146,8 @@
}, },
"prefilledVariables": { "prefilledVariables": {
"type": "object", "type": "object",
"additionalProperties": {} "additionalProperties": {},
"description": "[More info about prefilled variables.](https://docs.typebot.io/editor/variables#prefilled-variables)"
} }
}, },
"required": [ "required": [