"use client"; /** * 조건 분기 노드 속성 편집 */ import { useEffect, useState } from "react"; import { Plus, Trash2 } from "lucide-react"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { useFlowEditorStore } from "@/lib/stores/flowEditorStore"; import type { ConditionNodeData } from "@/types/node-editor"; interface ConditionPropertiesProps { nodeId: string; data: ConditionNodeData; } const OPERATORS = [ { value: "EQUALS", label: "같음 (=)" }, { value: "NOT_EQUALS", label: "같지 않음 (≠)" }, { value: "GREATER_THAN", label: "보다 큼 (>)" }, { value: "LESS_THAN", label: "보다 작음 (<)" }, { value: "GREATER_THAN_OR_EQUAL", label: "크거나 같음 (≥)" }, { value: "LESS_THAN_OR_EQUAL", label: "작거나 같음 (≤)" }, { value: "LIKE", label: "포함 (LIKE)" }, { value: "NOT_LIKE", label: "미포함 (NOT LIKE)" }, { value: "IN", label: "IN" }, { value: "NOT_IN", label: "NOT IN" }, { value: "IS_NULL", label: "NULL" }, { value: "IS_NOT_NULL", label: "NOT NULL" }, ] as const; export function ConditionProperties({ nodeId, data }: ConditionPropertiesProps) { const { updateNode } = useFlowEditorStore(); const [displayName, setDisplayName] = useState(data.displayName || "조건 분기"); const [conditions, setConditions] = useState(data.conditions || []); const [logic, setLogic] = useState<"AND" | "OR">(data.logic || "AND"); // 데이터 변경 시 로컬 상태 업데이트 useEffect(() => { setDisplayName(data.displayName || "조건 분기"); setConditions(data.conditions || []); setLogic(data.logic || "AND"); }, [data]); const handleAddCondition = () => { setConditions([ ...conditions, { field: "", operator: "EQUALS", value: "", }, ]); }; const handleRemoveCondition = (index: number) => { setConditions(conditions.filter((_, i) => i !== index)); }; const handleConditionChange = (index: number, field: string, value: any) => { const newConditions = [...conditions]; newConditions[index] = { ...newConditions[index], [field]: value }; setConditions(newConditions); }; const handleSave = () => { updateNode(nodeId, { displayName, conditions, logic, }); }; return (
{/* 기본 정보 */}

기본 정보

setDisplayName(e.target.value)} className="mt-1" placeholder="노드 표시 이름" />
{/* 조건식 */}

조건식

{conditions.length > 0 ? (
{conditions.map((condition, index) => (
조건 #{index + 1} {index > 0 && ( {logic} )}
handleConditionChange(index, "field", e.target.value)} placeholder="조건을 검사할 필드" className="mt-1 h-8 text-xs" />
{condition.operator !== "IS_NULL" && condition.operator !== "IS_NOT_NULL" && (
handleConditionChange(index, "value", e.target.value)} placeholder="비교할 값" className="mt-1 h-8 text-xs" />
)}
))}
) : (
조건식이 없습니다. "추가" 버튼을 클릭하세요.
)}
{/* 저장 버튼 */}
{/* 안내 */}
💡 AND: 모든 조건이 참이어야 TRUE 출력
💡 OR: 하나라도 참이면 TRUE 출력
⚡ TRUE 출력은 오른쪽 위, FALSE 출력은 오른쪽 아래입니다.
); }