import { LabeledFormGroup, SimpleCard, ToggleSwitch, useDomId } from '@shlinkio/shlink-frontend-kit'; import type { Settings } from '@shlinkio/shlink-web-component'; import classNames from 'classnames'; import { FormGroup, Input } from 'reactstrap'; import { FormText } from '../utils/forms/FormText'; type RealTimeUpdatesProps = { settings: Settings; toggleRealTimeUpdates: (enabled: boolean) => void; setRealTimeUpdatesInterval: (interval: number) => void; }; const intervalValue = (interval?: number) => (!interval ? '' : `${interval}`); export const RealTimeUpdatesSettings = ( { settings, toggleRealTimeUpdates, setRealTimeUpdatesInterval }: RealTimeUpdatesProps, ) => { const { realTimeUpdates = { enabled: true } } = settings; 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.'} )} ); };