2
0

⬆️ Upgrade dependencies

This commit is contained in:
Baptiste Arnaud
2023-05-02 14:37:34 -04:00
parent d50e280ab3
commit 68a15f5ac1
22 changed files with 3579 additions and 1960 deletions

View File

@@ -249,9 +249,8 @@ test('custom plans should work', async ({ page }) => {
description: 'Description of the deal',
})
await page.goto('/api/stripe/custom-plan-checkout')
await page.goto('/typebots?claimCustomPlan=true')
await expect(page.getByRole('list').getByText('$239.00')).toBeVisible()
await expect(page.getByText('Subscribe to Acme custom plan')).toBeVisible()
await expect(page.getByText('Description of the deal')).toBeVisible()
})

View File

@@ -73,8 +73,14 @@ const TextBubbleEditorContent = ({
setIsVariableDropdownOpen(false)
if (!rememberedSelection.current || !variable) return
ReactEditor.focus(editor as unknown as ReactEditor)
Transforms.select(editor as BaseEditor, rememberedSelection.current)
Transforms.insertText(editor as BaseEditor, '{{' + variable.name + '}}')
Transforms.select(
editor as unknown as BaseEditor,
rememberedSelection.current
)
Transforms.insertText(
editor as unknown as BaseEditor,
'{{' + variable.name + '}}'
)
}
const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {

View File

@@ -6,9 +6,8 @@ import {
BlockIndices,
Webhook,
} from '@typebot.io/schemas'
import { WritableDraft } from 'immer/dist/types/types-external'
import { SetTypebot } from '../TypebotProvider'
import produce from 'immer'
import { produce, Draft } from 'immer'
import { cleanUpEdgeDraft, deleteEdgeDraft } from './edges'
import { createId } from '@paralleldrive/cuid2'
import { byId, isWebhookBlock, blockHasItems } from '@typebot.io/lib'
@@ -94,13 +93,13 @@ export const blocksAction = (
const removeBlockFromGroup =
({ groupIndex, blockIndex }: BlockIndices) =>
(typebot: WritableDraft<Typebot>) => {
(typebot: Draft<Typebot>) => {
if (typebot.groups[groupIndex].blocks[blockIndex].type === 'start') return
typebot.groups[groupIndex].blocks.splice(blockIndex, 1)
}
export const createBlockDraft = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
block: DraggableBlock | DraggableBlockType,
groupId: string,
{ groupIndex, blockIndex }: BlockIndices,
@@ -126,7 +125,7 @@ export const createBlockDraft = (
}
const createNewBlock = async (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
type: DraggableBlockType,
groupId: string,
{ groupIndex, blockIndex }: BlockIndices,
@@ -139,7 +138,7 @@ const createNewBlock = async (
}
const moveBlockToGroup = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
block: DraggableBlock,
groupId: string,
{ groupIndex, blockIndex }: BlockIndices
@@ -205,13 +204,13 @@ export const duplicateBlockDraft =
}
export const deleteGroupDraft =
(typebot: WritableDraft<Typebot>) => (groupIndex: number) => {
(typebot: Draft<Typebot>) => (groupIndex: number) => {
if (typebot.groups[groupIndex].blocks.at(0)?.type === 'start') return
cleanUpEdgeDraft(typebot, typebot.groups[groupIndex].id)
typebot.groups.splice(groupIndex, 1)
}
export const removeEmptyGroups = (typebot: WritableDraft<Typebot>) => {
export const removeEmptyGroups = (typebot: Draft<Typebot>) => {
const emptyGroupsIndices = typebot.groups.reduce<number[]>(
(arr, group, idx) => {
group.blocks.length === 0 && arr.push(idx)

View File

@@ -6,9 +6,8 @@ import {
ItemIndices,
Block,
} from '@typebot.io/schemas'
import { WritableDraft } from 'immer/dist/types/types-external'
import { SetTypebot } from '../TypebotProvider'
import { produce } from 'immer'
import { Draft, produce } from 'immer'
import { byId, isDefined, blockHasItems } from '@typebot.io/lib'
import { createId } from '@paralleldrive/cuid2'
@@ -71,7 +70,7 @@ export const edgesAction = (setTypebot: SetTypebot): EdgesActions => ({
})
const addEdgeIdToBlock = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
edgeId: string,
{ groupIndex, blockIndex }: BlockIndices
) => {
@@ -79,7 +78,7 @@ const addEdgeIdToBlock = (
}
const addEdgeIdToItem = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
edgeId: string,
{ groupIndex, blockIndex, itemIndex }: ItemIndices
) =>
@@ -87,20 +86,14 @@ const addEdgeIdToItem = (
itemIndex
].outgoingEdgeId = edgeId)
export const deleteEdgeDraft = (
typebot: WritableDraft<Typebot>,
edgeId: string
) => {
export const deleteEdgeDraft = (typebot: Draft<Typebot>, edgeId: string) => {
const edgeIndex = typebot.edges.findIndex(byId(edgeId))
if (edgeIndex === -1) return
deleteOutgoingEdgeIdProps(typebot, edgeId)
typebot.edges.splice(edgeIndex, 1)
}
const deleteOutgoingEdgeIdProps = (
typebot: WritableDraft<Typebot>,
edgeId: string
) => {
const deleteOutgoingEdgeIdProps = (typebot: Draft<Typebot>, edgeId: string) => {
const edge = typebot.edges.find(byId(edgeId))
if (!edge) return
const fromGroupIndex = typebot.groups.findIndex(byId(edge.from.groupId))
@@ -125,7 +118,7 @@ const deleteOutgoingEdgeIdProps = (
}
export const cleanUpEdgeDraft = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
deletedNodeId: string
) => {
const edgesToDelete = typebot.edges.filter((edge) =>
@@ -141,7 +134,7 @@ export const cleanUpEdgeDraft = (
}
const removeExistingEdge = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
edge: Omit<Edge, 'id'>
) => {
typebot.edges = typebot.edges.filter((e) =>

View File

@@ -11,11 +11,10 @@ import {
ButtonItem,
} from '@typebot.io/schemas'
import { SetTypebot } from '../TypebotProvider'
import produce from 'immer'
import { Draft, produce } from 'immer'
import { cleanUpEdgeDraft } from './edges'
import { byId, blockHasItems } from '@typebot.io/lib'
import { createId } from '@paralleldrive/cuid2'
import { WritableDraft } from 'immer/dist/types/types-external'
type NewItem = Pick<
ConditionItem | ButtonItem,
@@ -30,11 +29,7 @@ export type ItemsActions = {
deleteItem: (indices: ItemIndices) => void
}
const createItem = (
block: WritableDraft<Block>,
item: NewItem,
itemIndex: number
) => {
const createItem = (block: Draft<Block>, item: NewItem, itemIndex: number) => {
switch (block.type) {
case LogicBlockType.CONDITION: {
if (item.type === ItemType.CONDITION) {

View File

@@ -1,7 +1,6 @@
import { Typebot, Variable } from '@typebot.io/schemas'
import { WritableDraft } from 'immer/dist/types/types-external'
import { SetTypebot } from '../TypebotProvider'
import { produce } from 'immer'
import { Draft, produce } from 'immer'
export type VariablesActions = {
createVariable: (variable: Variable) => void
@@ -39,7 +38,7 @@ export const variablesAction = (setTypebot: SetTypebot): VariablesActions => ({
})
export const deleteVariableDraft = (
typebot: WritableDraft<Typebot>,
typebot: Draft<Typebot>,
variableId: string
) => {
const index = typebot.variables.findIndex((v) => v.id === variableId)