import React from 'react'; import PropTypes from 'prop-types'; import { TextValidator, ValidatorForm, SelectValidator } from 'react-material-ui-form-validator'; import { withStyles } from '@material-ui/core/styles'; import FormControlLabel from '@material-ui/core/FormControlLabel'; import MenuItem from '@material-ui/core/MenuItem'; import Switch from '@material-ui/core/Switch'; import Button from '@material-ui/core/Button'; import SaveIcon from '@material-ui/icons/Save'; import isIP from '../validators/isIP'; import isHostname from '../validators/isHostname'; import or from '../validators/or'; import { timeZoneSelectItems, selectedTimeZone, TIME_ZONES } from '../constants/TZ'; const styles = theme => ({ switchControl: { width: "100%", marginTop: theme.spacing(2), marginBottom: theme.spacing(0.5) }, textField: { width: "100%" }, button: { marginRight: theme.spacing(2), marginTop: theme.spacing(2), } }); class NTPSettingsForm extends React.Component { componentWillMount() { ValidatorForm.addValidationRule('isIPOrHostname', or(isIP, isHostname)); } changeTimeZone = (event) => { const { ntpSettings, setData } = this.props; setData({ ...ntpSettings, tz_label: event.target.value, tz_format: TIME_ZONES[event.target.value] }); } render() { const { classes, ntpSettings, handleValueChange, handleCheckboxChange, onSubmit, onReset } = this.props; return ( } label="Enable NTP?" /> Time zone... {timeZoneSelectItems()} ); } } NTPSettingsForm.propTypes = { classes: PropTypes.object.isRequired, ntpSettings: PropTypes.object, onSubmit: PropTypes.func.isRequired, onReset: PropTypes.func.isRequired, handleValueChange: PropTypes.func.isRequired, }; export default withStyles(styles)(NTPSettingsForm);