"use client"; import React from "react"; import { X } from "lucide-react"; export function WorkflowNode({ node, scale, onDragStart, onConnectionStart, onConnectionEnd, onDelete, isSelected, onClick, }) { const getNodeTypeLabel = () => { switch (node.type) { case "trigger": return { label: "Trigger", color: "text-emerald-600" }; case "router": return { label: "Router", color: "text-slate-500" }; case "action": return { label: "Action", color: "text-primary" }; default: return { label: "Action", color: "text-primary" }; } }; const typeInfo = getNodeTypeLabel(); const handleMouseDownOnHandle = (e, handle) => { e.stopPropagation(); onConnectionStart(node.id, handle); }; const handleMouseUpOnHandle = (e, handle) => { e.stopPropagation(); onConnectionEnd(node.id, handle); }; return (
{/* Type Label */}
{typeInfo.label} {node.actionNumber !== undefined && ( {node.actionNumber} )}
{/* Node Card */}
{/* Left Handle - for incoming connections */}
handleMouseDownOnHandle(e, "left")} onMouseUp={(e) => handleMouseUpOnHandle(e, "left")} /> {/* Delete Button */} {/* Node Content */}
onDragStart(e, node.id)} onClick={(e) => { e.stopPropagation(); onClick(); }} >
{node.icon || '⚙️'}
{node.title || node.label}
{node.subtitle || node.description || "Configure action"}
{/* Right Handle - for outgoing connections */}
handleMouseDownOnHandle(e, "right")} onMouseUp={(e) => handleMouseUpOnHandle(e, "right")} /> {/* Error Badge */} {node.hasError && (
1
)}
); } export default WorkflowNode;