import { FormGroup, Input } from 'reactstrap'; import classNames from 'classnames'; import { ToggleSwitch } from '../utils/ToggleSwitch'; import { SimpleCard } from '../utils/SimpleCard'; import { FormText } from '../utils/forms/FormText'; import { LabeledFormGroup } from '../utils/forms/LabeledFormGroup'; import type { Settings } from './reducers/settings'; import { useDomId } from '../utils/helpers/hooks'; interface RealTimeUpdatesProps { settings: Settings; toggleRealTimeUpdates: (enabled: boolean) => void; setRealTimeUpdatesInterval: (interval: number) => void; } const intervalValue = (interval?: number) => (!interval ? '' : `${interval}`); export const RealTimeUpdatesSettings = ( { settings: { realTimeUpdates }, toggleRealTimeUpdates, setRealTimeUpdatesInterval }: RealTimeUpdatesProps, ) => { const inputId = useDomId(); return ( Enable or disable real-time updates. Real-time updates are currently being {realTimeUpdates.enabled ? 'processed' : 'ignored'}. setRealTimeUpdatesInterval(Number(target.value))} /> {realTimeUpdates.enabled && ( {realTimeUpdates.interval !== undefined && realTimeUpdates.interval > 0 && ( Updates will be reflected in the UI every {realTimeUpdates.interval} minute{realTimeUpdates.interval > 1 && 's'}. )} {!realTimeUpdates.interval && 'Updates will be reflected in the UI as soon as they happen.'} )} ); };