2
0

♻️ (builder) Change to features-centric folder structure

This commit is contained in:
Baptiste Arnaud
2022-11-15 09:35:48 +01:00
committed by Baptiste Arnaud
parent 3686465a85
commit 643571fe7d
683 changed files with 3907 additions and 3643 deletions

View File

@ -0,0 +1,70 @@
import cuid from 'cuid'
import {
defaultSettings,
defaultTheme,
Group,
StartBlock,
Typebot,
} from 'models'
export const parseNewTypebot = ({
folderId,
name,
ownerAvatarUrl,
workspaceId,
isBrandingEnabled = true,
}: {
folderId: string | null
workspaceId: string
name: string
ownerAvatarUrl?: string
isBrandingEnabled?: boolean
}): Omit<
Typebot,
| 'createdAt'
| 'updatedAt'
| 'id'
| 'publishedTypebotId'
| 'publicId'
| 'customDomain'
| 'icon'
| 'isArchived'
| 'isClosed'
> => {
const startGroupId = cuid()
const startBlockId = cuid()
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,
workspaceId,
groups: [startGroup],
edges: [],
variables: [],
theme: {
...defaultTheme,
chat: {
...defaultTheme.chat,
hostAvatar: { isEnabled: true, url: ownerAvatarUrl },
},
},
settings: {
...defaultSettings,
general: {
...defaultSettings.general,
isBrandingEnabled,
},
},
}
}