import { memo } from "react"; import { useTranslation } from "react-i18next"; import { Button, theme } from "antd"; import { type WorkflowNode } from "@/domain/workflow"; import { useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; import AddNode from "./AddNode"; import WorkflowElement from "../WorkflowElement"; import { type SharedNodeProps } from "./_SharedNode"; export type BrandNodeProps = SharedNodeProps; const BranchNode = ({ node, disabled }: BrandNodeProps) => { const { t } = useTranslation(); const { addBranch } = useWorkflowStore(useZustandShallowSelector(["addBranch"])); const { token: themeToken } = theme.useToken(); const renderBranch = (node: WorkflowNode, branchNodeId?: string, branchIndex?: number) => { const elements: JSX.Element[] = []; let current = node as typeof node | undefined; while (current) { elements.push(); current = current.next; } return elements; }; return ( <>
{node.branches?.map((branch, index) => (
{index == 0 && ( <>
)} {node.branches && index == node.branches.length - 1 && ( <>
)}
{renderBranch(branch, node.id, index)}
))}
); }; export default memo(BranchNode);