import { Button, Input, Select, Tooltip, Typography } from 'antd'; import { ChartLine, CircleX, Trash } from 'lucide-react'; import { useMemo, useState } from 'react'; import { useCreateAlertState } from '../context'; import { AlertThresholdOperator } from '../context/types'; import { ThresholdItemProps } from './types'; function ThresholdItem({ threshold, updateThreshold, removeThreshold, showRemoveButton, channels, units, }: ThresholdItemProps): JSX.Element { const { thresholdState } = useCreateAlertState(); const [showRecoveryThreshold, setShowRecoveryThreshold] = useState(false); const yAxisUnitSelect = useMemo(() => { let component = ( updateThreshold(threshold.id, 'unit', value)} style={{ width: 150 }} options={units} disabled={units.length === 0} /> ); } return component; }, [units, threshold.unit, updateThreshold, threshold.id]); const getOperatorSymbol = (): string => { switch (thresholdState.operator) { case AlertThresholdOperator.IS_ABOVE: return '>'; case AlertThresholdOperator.IS_BELOW: return '<'; case AlertThresholdOperator.IS_EQUAL_TO: return '='; case AlertThresholdOperator.IS_NOT_EQUAL_TO: return '!='; default: return ''; } }; const addRecoveryThreshold = (): void => { // Recovery threshold - hidden for now // setShowRecoveryThreshold(true); // updateThreshold(threshold.id, 'recoveryThresholdValue', 0); }; const removeRecoveryThreshold = (): void => { setShowRecoveryThreshold(false); updateThreshold(threshold.id, 'recoveryThresholdValue', null); }; return (
updateThreshold(threshold.id, 'label', e.target.value) } style={{ width: 200 }} /> on value {getOperatorSymbol()} updateThreshold(threshold.id, 'thresholdValue', e.target.value) } style={{ width: 100 }} type="number" /> {yAxisUnitSelect} send to updateThreshold(threshold.id, 'recoveryThresholdValue', e.target.value) } style={{ width: 100 }} type="number" />
); } export default ThresholdItem;