'use strict'; import React from 'react'; export default class DetailsStep extends React.Component { constructor (props) { super(props); this.state = { ota: false, ssl: false }; } handleOtaCheckbox (e) { this.setState({ ota: e.target.checked }); } handleSslCheckbox (e) { this.setState({ ssl: e.target.checked }); } handleFormSubmit (e) { e.preventDefault(); let otaCreds = {}; otaCreds.enabled = false; if (this.state.ota) { otaCreds.enabled = true; otaCreds.host = this.refs.host.value; otaCreds.port = parseInt(this.refs.port.value, 10); otaCreds.ssl = false; if (this.state.ssl) { otaCreds.ssl = true; if (this.refs.fingerprint.value !== '') otaCreds['fingerprint'] = this.refs.fingerprint.value; } otaCreds.path = this.refs.path.value; } this.props.setName(this.refs.name.value); if (this.refs.deviceId.value !== '') this.props.setDeviceId(this.refs.deviceId.value); this.props.setOtaCreds(otaCreds); this.props.nextStep(); } render () { return (

A few details before finishing the configuration.

this.handleFormSubmit(e) }>

Required.

Optional. The default value is the hardware device ID. MAY be composed of lowercase letters from a to z, numbers from 0 to 9, and it MAY contain -, but MUST NOT start or end with a -

{(() => { if (this.state.ota) { return (

Required.

Required.

{(() => { if (this.state.ssl) { return (

Optional. Can be lower-case, upper-case, separated by spaced or :.

); } })()}

Required.


); } })()}

); } } if (process.env.NODE_ENV !== 'production') { // for Preact DetailsStep.propTypes = { nextStep: React.PropTypes.func.isRequired, mqttConfig: React.PropTypes.object.isRequired, setName: React.PropTypes.func.isRequired, setDeviceId: React.PropTypes.func.isRequired, setOtaCreds: React.PropTypes.func.isRequired }; }