import { Button } from "@/components/ui/button"; import AddNode from "./AddNode"; import { WorkflowBranchNode, WorkflowNode } from "@/domain/workflow"; import NodeRender from "./NodeRender"; import { memo } from "react"; import { BrandNodeProps } from "./types"; import { useWorkflowStore, WorkflowState } from "@/providers/workflow"; import { useShallow } from "zustand/shallow"; import { useTranslation } from "react-i18next"; const selectState = (state: WorkflowState) => ({ addBranch: state.addBranch, }); const BranchNode = memo(({ data }: BrandNodeProps) => { const { addBranch } = useWorkflowStore(useShallow(selectState)); const { t } = useTranslation(); const renderNodes = (node: WorkflowBranchNode | WorkflowNode | undefined, branchNodeId?: string, branchIndex?: number) => { const elements: JSX.Element[] = []; let current = node; while (current) { elements.push(); current = current.next; } return elements; }; return ( <>
{data.branches.map((branch, index) => (
{index == 0 && ( <>
)} {index == data.branches.length - 1 && ( <>
)} {/* 条件 1 */}
{renderNodes(branch, data.id, index)}
))}
); }); export default BranchNode;