import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Field, reduxForm } from 'redux-form';
import { withNamespaces, Trans } from 'react-i18next';
import flow from 'lodash/flow';
import { R_IPV4 } from '../../../helpers/constants';
const required = (value) => {
if (value || value === 0) {
return false;
}
return form_error_required;
};
const ipv4 = (value) => {
if (value && !new RegExp(R_IPV4).test(value)) {
return form_error_ip_format;
}
return false;
};
const isPositive = (value) => {
if ((value || value === 0) && (value <= 0)) {
return form_error_positive;
}
return false;
};
const toNumber = value => value && parseInt(value, 10);
const renderField = ({
input, className, placeholder, type, disabled, meta: { touched, error },
}) => (
{!disabled && touched && (error && {error})}
);
const Form = (props) => {
const {
t,
handleSubmit,
pristine,
submitting,
} = props;
return (
);
};
Form.propTypes = {
handleSubmit: PropTypes.func,
pristine: PropTypes.bool,
submitting: PropTypes.bool,
interfaces: PropTypes.object,
processing: PropTypes.bool,
initialValues: PropTypes.object,
t: PropTypes.func,
};
export default flow([
withNamespaces(),
reduxForm({ form: 'dhcpForm' }),
])(Form);