2
0

♻️ Normalize data

This commit is contained in:
Baptiste Arnaud
2022-01-06 09:40:56 +01:00
parent 6c1e0fd345
commit 9fa4c7dffa
114 changed files with 1545 additions and 1632 deletions

View File

@ -0,0 +1,75 @@
import {
Block,
StepType,
Theme,
BackgroundType,
Settings,
Typebot,
Table,
Step,
} from 'models'
export const parseTestTypebot = ({
id,
ownerId,
name,
blocks,
steps,
}: {
id: string
ownerId: string
name: string
blocks: Table<Block>
steps: Table<Step>
}): Typebot => {
const theme: Theme = {
general: {
font: 'Open Sans',
background: { type: BackgroundType.NONE, content: '#ffffff' },
},
}
const settings: Settings = {
typingEmulation: {
enabled: true,
speed: 300,
maxDelay: 1.5,
},
}
return {
id,
folderId: null,
name,
ownerId,
theme,
settings,
createdAt: new Date(),
blocks: {
byId: {
block0: {
id: 'block0',
title: 'Block #0',
stepIds: ['step0'],
graphCoordinates: { x: 0, y: 0 },
},
...blocks.byId,
},
allIds: ['block0', ...blocks.allIds],
},
steps: {
byId: {
step0: {
id: 'step0',
type: StepType.START,
blockId: 'block0',
label: 'Start',
target: { blockId: 'block1' },
},
...steps.byId,
},
allIds: ['step0', ...steps.allIds],
},
publicId: null,
publishedTypebotId: null,
updatedAt: new Date(),
}
}