'use strict'; import React from 'react'; export default class MqttStep extends React.Component { constructor (props) { super(props); this.state = { auth: false, showPassword: false, ssl: false }; } handleSslCheckbox (e) { this.setState({ ssl: e.target.checked }); } handleAuthCheckbox (e) { this.setState({ auth: e.target.checked }); } handleHiddenCheckbox (e) { this.setState({ showPassword: e.target.checked }); } handleFormSubmit (e) { e.preventDefault(); let creds = {}; creds.host = this.refs.host.value; creds.port = parseInt(this.refs.port.value, 10); if (this.refs.baseTopic.value !== '') creds['base_topic'] = this.refs.baseTopic.value; creds.ssl = false; if (this.state.ssl) { creds.ssl = true; if (this.refs.fingerprint.value !== '') creds['fingerprint'] = this.refs.fingerprint.value; } creds.auth = false; if (this.state.auth) { creds.auth = true; creds.username = this.refs.username.value; creds.password = this.refs.password.value; } this.props.setMqttCreds(creds); this.props.nextStep(); } render () { return (
Enter the MQTT credentials.