@ -92,6 +92,7 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps<WorkflowNode>)
// Handle delete switch
// Handle delete switch
const handleDelete = useCallback (
const handleDelete = useCallback (
( switchId : string ) = > {
( switchId : string ) = > {
if ( nodeData . switches . length <= 1 ) return ;
const updatedSwitches = nodeData . switches . filter ( ( sw ) = > sw . id !== switchId ) ;
const updatedSwitches = nodeData . switches . filter ( ( sw ) = > sw . id !== switchId ) ;
updateNodeData ( id , { switches : updatedSwitches } ) ;
updateNodeData ( id , { switches : updatedSwitches } ) ;
@ -227,7 +228,8 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps<WorkflowNode>)
< / span >
< / span >
) }
) }
{ /* Delete button */ }
{ /* Delete button (hidden if only one switch) */ }
{ nodeData . switches . length > 1 && (
< button
< button
className = "opacity-0 group-hover:opacity-100 text-neutral-400 hover:text-red-400 transition-opacity"
className = "opacity-0 group-hover:opacity-100 text-neutral-400 hover:text-red-400 transition-opacity"
onClick = { ( ) = > handleDelete ( sw . id ) }
onClick = { ( ) = > handleDelete ( sw . id ) }
@ -247,6 +249,7 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps<WorkflowNode>)
/ >
/ >
< / svg >
< / svg >
< / button >
< / button >
) }
< / div >
< / div >
) ) }
) ) }