import React from 'react'; import PropTypes from 'prop-types'; import { Field, reduxForm } from 'redux-form'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; import { renderRadioField, toNumber, CheckboxField } from '../../../helpers/form'; import { FORM_NAME, STATS_INTERVALS_DAYS, DISABLED_STATS_INTERVAL } from '../../../helpers/constants'; import '../FormButton.css'; const getIntervalTitle = (interval, t) => { switch (interval) { case 1: return t('interval_24_hour'); default: return t('interval_days', { count: interval }); } }; const Form = (props) => { const { handleSubmit, change, processing, submitting, invalid, handleReset, processingReset, t, } = props; return (
{ if (event.target.checked) { change('interval', STATS_INTERVALS_DAYS[0]); } else { change('interval', DISABLED_STATS_INTERVAL); } }} />
statistics_retention_desc
{STATS_INTERVALS_DAYS.map((interval) => ( { if (event.target.checked) { change('enabled', true); } }} /> ))}
); }; Form.propTypes = { handleSubmit: PropTypes.func.isRequired, handleReset: PropTypes.func.isRequired, change: PropTypes.func.isRequired, submitting: PropTypes.bool.isRequired, invalid: PropTypes.bool.isRequired, processing: PropTypes.bool.isRequired, processingReset: PropTypes.bool.isRequired, t: PropTypes.func.isRequired, }; export default flow([ withTranslation(), reduxForm({ form: FORM_NAME.STATS_CONFIG }), ])(Form);