diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 1f4a494bb..79ac65961 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -30,6 +30,7 @@ import { } from "../types/zustand/flow"; import { buildVertices } from "../utils/buildUtils"; import { + checkChatInput, cleanEdges, getHandleId, getNodeId, @@ -228,6 +229,10 @@ const useFlowStore = create((set, get) => ({ ); }, paste: (selection, position) => { + if(selection.nodes.some((node) => node.data.type === "ChatInput") && checkChatInput(get().nodes)){ + useAlertStore.getState().setErrorData({title: "Error pasting components", list: ["You can only have one ChatInput component in the flow"]}); + return; + } let minimumX = Infinity; let minimumY = Infinity; let idsMap = {}; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 7def5d274..1d9e81d94 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -44,6 +44,10 @@ import { } from "./utils"; const uid = new ShortUniqueId({ length: 5 }); +export function checkChatInput(nodes: Node[]) { + return nodes.some((node) => node.data.type === "ChatInput"); +} + export function cleanEdges(nodes: Node[], edges: Edge[]) { let newEdges = cloneDeep(edges); edges.forEach((edge) => {