♻️ (builder) Change to features-centric folder structure
This commit is contained in:
committed by
Baptiste Arnaud
parent
3686465a85
commit
643571fe7d
70
apps/builder/src/features/dashboard/api/parseNewTypebot.ts
Normal file
70
apps/builder/src/features/dashboard/api/parseNewTypebot.ts
Normal 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,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user