2
0

🐛 Deprecate blockId field in items

This commit is contained in:
Baptiste Arnaud
2023-08-16 09:15:19 +02:00
parent f508c97ee1
commit 019f72ac7e
9 changed files with 34 additions and 37 deletions

View File

@@ -54,10 +54,7 @@ export const ButtonsItemNode = ({ item, indices, isMouseOver }: Props) => {
const handlePlusClick = () => {
const itemIndex = indices.itemIndex + 1
createItem(
{ blockId: item.blockId, type: ItemType.BUTTON },
{ ...indices, itemIndex }
)
createItem({ type: ItemType.BUTTON }, { ...indices, itemIndex })
}
const updateItemSettings = (settings: Omit<ButtonItem, 'content'>) => {

View File

@@ -40,10 +40,7 @@ export const PictureChoiceItemNode = ({
const handlePlusClick = (e: React.MouseEvent) => {
e.stopPropagation()
const itemIndex = indices.itemIndex + 1
createItem(
{ blockId: item.blockId, type: ItemType.PICTURE_CHOICE },
{ ...indices, itemIndex }
)
createItem({ type: ItemType.PICTURE_CHOICE }, { ...indices, itemIndex })
}
const handleMouseDown = (e: React.MouseEvent) => e.stopPropagation()
@@ -139,6 +136,10 @@ export const PictureChoiceItemNode = ({
<PictureChoiceItemSettings
typebotId={typebot.id}
item={item}
blockId={
typebot.groups[indices.groupIndex].blocks[indices.blockIndex]
.id
}
onItemChange={handleItemChange}
/>
)}

View File

@@ -17,12 +17,14 @@ import { Condition, LogicalOperator } from '@typebot.io/schemas'
type Props = {
typebotId: string
blockId: string
item: PictureChoiceItem
onItemChange: (updates: Partial<PictureChoiceItem>) => void
}
export const PictureChoiceItemSettings = ({
typebotId,
blockId,
item,
onItemChange,
}: Props) => {
@@ -67,7 +69,7 @@ export const PictureChoiceItemSettings = ({
</PopoverTrigger>
<PopoverContent p="4" w="500px">
<ImageUploadContent
filePath={`typebots/${typebotId}/blocks/${item.blockId}/items/${item.id}`}
filePath={`typebots/${typebotId}/blocks/${blockId}/items/${item.id}`}
defaultUrl={item.pictureSrc}
onSubmit={(url) => {
updateImage(url)

View File

@@ -25,7 +25,6 @@ test.describe.parallel('Picture choice input block', () => {
items: [
{
id: 'choice1',
blockId: 'block1',
type: ItemType.PICTURE_CHOICE,
},
],

View File

@@ -54,7 +54,6 @@ export const ConditionItemNode = ({ item, isMouseOver, indices }: Props) => {
const newItemId = createId()
createItem(
{
blockId: item.blockId,
type: ItemType.CONDITION,
id: newItemId,
},

View File

@@ -117,7 +117,6 @@ const duplicateTypebot = (
...newIds,
items: block.items.map((item) => ({
...item,
blockId: blockIdsMapping.get(item.blockId) as string,
outgoingEdgeId: item.outgoingEdgeId
? (edgeIdsMapping.get(item.outgoingEdgeId) as string)
: undefined,