99 lines
4.0 KiB
TypeScript
99 lines
4.0 KiB
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* UPDATE 액션 노드
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { memo } from "react";
|
||
|
|
import { Handle, Position, NodeProps } from "reactflow";
|
||
|
|
import { Edit } from "lucide-react";
|
||
|
|
import type { UpdateActionNodeData } from "@/types/node-editor";
|
||
|
|
|
||
|
|
export const UpdateActionNode = memo(({ data, selected }: NodeProps<UpdateActionNodeData>) => {
|
||
|
|
return (
|
||
|
|
<div
|
||
|
|
className={`min-w-[250px] rounded-lg border-2 bg-white shadow-md transition-all ${
|
||
|
|
selected ? "border-blue-500 shadow-lg" : "border-gray-200"
|
||
|
|
}`}
|
||
|
|
>
|
||
|
|
{/* 입력 핸들 */}
|
||
|
|
<Handle type="target" position={Position.Left} className="!h-3 !w-3 !border-2 !border-blue-500 !bg-white" />
|
||
|
|
|
||
|
|
{/* 헤더 */}
|
||
|
|
<div className="flex items-center gap-2 rounded-t-lg bg-blue-500 px-3 py-2 text-white">
|
||
|
|
<Edit className="h-4 w-4" />
|
||
|
|
<div className="flex-1">
|
||
|
|
<div className="text-sm font-semibold">UPDATE</div>
|
||
|
|
<div className="text-xs opacity-80">{data.displayName || data.targetTable}</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* 본문 */}
|
||
|
|
<div className="p-3">
|
||
|
|
<div className="mb-2 text-xs font-medium text-gray-500">
|
||
|
|
타겟: {data.displayName || data.targetTable}
|
||
|
|
{data.targetTable && data.displayName && data.displayName !== data.targetTable && (
|
||
|
|
<span className="ml-1 font-mono text-gray-400">({data.targetTable})</span>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* WHERE 조건 */}
|
||
|
|
{data.whereConditions && data.whereConditions.length > 0 && (
|
||
|
|
<div className="mb-3 space-y-1">
|
||
|
|
<div className="text-xs font-medium text-gray-700">WHERE 조건:</div>
|
||
|
|
<div className="max-h-[80px] space-y-1 overflow-y-auto">
|
||
|
|
{data.whereConditions.slice(0, 2).map((condition, idx) => (
|
||
|
|
<div key={idx} className="rounded bg-blue-50 px-2 py-1 text-xs">
|
||
|
|
<span className="font-mono text-gray-700">{condition.fieldLabel || condition.field}</span>
|
||
|
|
<span className="mx-1 text-blue-600">{condition.operator}</span>
|
||
|
|
<span className="text-gray-600">
|
||
|
|
{condition.sourceFieldLabel || condition.sourceField || condition.staticValue || "?"}
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
))}
|
||
|
|
{data.whereConditions.length > 2 && (
|
||
|
|
<div className="text-xs text-gray-400">... 외 {data.whereConditions.length - 2}개</div>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
|
||
|
|
{/* 필드 매핑 */}
|
||
|
|
{data.fieldMappings && data.fieldMappings.length > 0 && (
|
||
|
|
<div className="space-y-1">
|
||
|
|
<div className="text-xs font-medium text-gray-700">업데이트 필드:</div>
|
||
|
|
<div className="max-h-[100px] space-y-1 overflow-y-auto">
|
||
|
|
{data.fieldMappings.slice(0, 3).map((mapping, idx) => (
|
||
|
|
<div key={idx} className="rounded bg-gray-50 px-2 py-1 text-xs">
|
||
|
|
<span className="text-gray-600">
|
||
|
|
{mapping.sourceFieldLabel || mapping.sourceField || mapping.staticValue || "?"}
|
||
|
|
</span>
|
||
|
|
<span className="mx-1 text-gray-400">→</span>
|
||
|
|
<span className="font-mono text-gray-700">{mapping.targetFieldLabel || mapping.targetField}</span>
|
||
|
|
</div>
|
||
|
|
))}
|
||
|
|
{data.fieldMappings.length > 3 && (
|
||
|
|
<div className="text-xs text-gray-400">... 외 {data.fieldMappings.length - 3}개</div>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
|
||
|
|
{/* 옵션 */}
|
||
|
|
{data.options && data.options.batchSize && (
|
||
|
|
<div className="mt-2">
|
||
|
|
<span className="rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-700">
|
||
|
|
배치 {data.options.batchSize}건
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* 출력 핸들 */}
|
||
|
|
<Handle type="source" position={Position.Right} className="!h-3 !w-3 !border-2 !border-blue-500 !bg-white" />
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
UpdateActionNode.displayName = "UpdateActionNode";
|