'use client' import { BaseEdge, EdgeLabelRenderer, EdgeProps, getSmoothStepPath, } from 'reactflow' import type { Condition } from '@/types/flowchart' type ConditionalEdgeData = { condition?: Condition } export default function ConditionalEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, markerEnd, selected, }: EdgeProps) { const [edgePath, labelX, labelY] = getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, }) const hasCondition = !!data?.condition // Format condition as readable label const conditionLabel = hasCondition ? `${data.condition!.variableName} ${data.condition!.operator} ${data.condition!.value}` : null return ( <> {conditionLabel && (
{conditionLabel}
)} ) }