🚸 Improve parsing preprocessing on typebots

This commit is contained in:
Baptiste Arnaud
2023-08-23 10:57:38 +02:00
parent fe54888350
commit 0acede92ef
24 changed files with 132 additions and 584 deletions

View File

@@ -1,62 +0,0 @@
import { createId } from '@paralleldrive/cuid2'
import {
defaultSettings,
defaultTheme,
Group,
StartBlock,
Typebot,
} from '@typebot.io/schemas'
// TODO: remove
export type NewTypebotProps = Omit<
Typebot,
| 'createdAt'
| 'updatedAt'
| 'id'
| 'publicId'
| 'customDomain'
| 'icon'
| 'isArchived'
| 'isClosed'
| 'resultsTablePreferences'
>
export const parseNewTypebot = ({
folderId,
name,
workspaceId,
isBrandingEnabled = true,
}: {
folderId: string | null
workspaceId: string
name: string
ownerAvatarUrl?: string
isBrandingEnabled?: boolean
}): NewTypebotProps => {
const startGroupId = createId()
const startBlockId = createId()
const startBlock: StartBlock = {
groupId: startGroupId,
id: startBlockId,
label: 'Start',
type: 'start',
}
const startGroup: Group = {
id: startGroupId,
title: 'Start',
graphCoordinates: { x: 0, y: 0 },
blocks: [startBlock],
}
return {
folderId,
name,
version: '4',
workspaceId,
groups: [startGroup],
edges: [],
variables: [],
selectedThemeTemplateId: null,
theme: defaultTheme,
settings: defaultSettings({ isBrandingEnabled }),
}
}