🚸 Improve parsing preprocessing on typebots
This commit is contained in:
@@ -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 }),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user