/* eslint-disable react/no-multi-comp */ import * as React from 'react'; import {ISuperdesk, IConfigComponentProps} from 'superdesk-api'; import {IDateTimeFieldConfig, defaultDateTimeConfig} from './extension'; import {Button, FormLabel, IconButton} from 'superdesk-ui-framework/react'; export function getConfigComponent(superdesk: ISuperdesk) { const gettext = superdesk.localization.gettext; const {Spacer} = superdesk.components; return class DateTimeFieldConfig extends React.PureComponent> { render() { const config: IDateTimeFieldConfig = this.props.config ?? defaultDateTimeConfig; const {onChange} = this.props; return (
{ onChange({ ...config, initial_offset_minutes: parseInt(event.target.value, 10), }); }} style={{width: 54}} />
{gettext('minutes')}
{ config.increment_steps.map((value, i) => ( { onChange({ ...config, increment_steps: config.increment_steps.filter((_, _i) => i !== _i), }); }} />
{ const nextIncrementSteps = config.increment_steps .map((_value, j) => { if (j === i) { return parseInt(event.target.value, 10); } else { return _value; } }); onChange({ ...config, increment_steps: nextIncrementSteps, }); }} style={{width: 54}} />
{gettext('minutes')}
)) }