"use client";

import { memo } from "react";
import { NodeProps } from "reactflow";
import { Pencil } from "lucide-react";
import { CompactNodeShell } from "./CompactNodeShell";
import type { UpdateActionNodeData } from "@/types/node-editor";

export const UpdateActionNode = memo(({ data, selected }: NodeProps<UpdateActionNodeData>) => {
  const mappingCount = data.fieldMappings?.length || 0;
  const whereCount = data.whereConditions?.length || 0;
  const summary = data.targetTable
    ? `${data.targetTable} (${mappingCount}개 필드, ${whereCount}개 조건)`
    : "대상 테이블을 선택해 주세요";

  return (
    <CompactNodeShell
      color="#3B82F6"
      label={data.displayName || "UPDATE"}
      summary={summary}
      icon={<Pencil className="h-3.5 w-3.5" />}
      selected={selected}
    />
  );
});

UpdateActionNode.displayName = "UpdateActionNode";
