"use client"; /** * 조건 분기 노드 */ import { memo } from "react"; import { Handle, Position, NodeProps } from "reactflow"; import { Zap, Check, X } from "lucide-react"; import type { ConditionNodeData } from "@/types/node-editor"; const OPERATOR_LABELS: Record = { EQUALS: "=", NOT_EQUALS: "≠", GREATER_THAN: ">", LESS_THAN: "<", GREATER_THAN_OR_EQUAL: "≥", LESS_THAN_OR_EQUAL: "≤", LIKE: "포함", NOT_LIKE: "미포함", IN: "IN", NOT_IN: "NOT IN", IS_NULL: "NULL", IS_NOT_NULL: "NOT NULL", }; export const ConditionNode = memo(({ data, selected }: NodeProps) => { return (
{/* 입력 핸들 */} {/* 헤더 */}
조건 검사
{data.displayName || "조건 분기"}
{/* 본문 */}
{data.conditions && data.conditions.length > 0 ? (
조건식: ({data.conditions.length}개)
{data.conditions.slice(0, 4).map((condition, idx) => (
{idx > 0 && (
{data.logic}
)}
{condition.field} {OPERATOR_LABELS[condition.operator] || condition.operator} {condition.value !== null && condition.value !== undefined && ( {typeof condition.value === "string" ? `"${condition.value}"` : String(condition.value)} )}
))} {data.conditions.length > 4 && (
... 외 {data.conditions.length - 4}개
)}
) : (
조건 없음
)}
{/* 분기 출력 핸들 */}
{/* TRUE 출력 - 오른쪽 위 */}
TRUE
{/* FALSE 출력 - 오른쪽 아래 */}
FALSE
); }); ConditionNode.displayName = "ConditionNode";