import { memo } from "react"; import { useTranslation } from "react-i18next"; import { CloseCircleOutlined as CloseCircleOutlinedIcon, EllipsisOutlined as EllipsisOutlinedIcon } from "@ant-design/icons"; import { Button, Card, Dropdown, Popover } from "antd"; import { produce } from "immer"; import { type WorkflowNode } from "@/domain/workflow"; import { useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; import AddNode from "./AddNode"; export type ConditionNodeProps = { node: WorkflowNode; branchId: string; branchIndex: number; disabled?: boolean; }; const ConditionNode = ({ node, branchId, branchIndex, disabled }: ConditionNodeProps) => { const { t } = useTranslation(); const { updateNode, removeBranch } = useWorkflowStore(useZustandShallowSelector(["updateNode", "removeBranch"])); const handleNodeNameBlur = (e: React.FocusEvent) => { const oldName = node.name; const newName = e.target.innerText.trim(); if (oldName === newName) { return; } updateNode( produce(node, (draft) => { draft.name = newName; }) ); }; return ( <> , danger: true, onClick: () => { if (disabled) return; removeBranch(branchId!, branchIndex!); }, }, ], }} trigger={["click"]} >