'use client' import { memo, useState, useCallback } from 'react' import { Handle, Position } from '@xyflow/react' import type { NodeProps } from '@xyflow/react' import type { ThresholdNodeData } from '@/lib/types' function ThresholdNode({ data, selected }: NodeProps) { const nodeData = data as ThresholdNodeData const [minThreshold, setMinThreshold] = useState(nodeData.minThreshold) const [maxThreshold, setMaxThreshold] = useState(nodeData.maxThreshold) const currentValue = nodeData.currentValue // Calculate status const getStatus = () => { if (currentValue < minThreshold) return { label: 'Below Min', color: 'red', bg: 'bg-red-500' } if (currentValue > maxThreshold) return { label: 'Overflow', color: 'amber', bg: 'bg-amber-500' } return { label: 'Active', color: 'green', bg: 'bg-emerald-500' } } const status = getStatus() const fillPercent = Math.min(100, Math.max(0, ((currentValue - minThreshold) / (maxThreshold - minThreshold)) * 100)) return (
Current Value