import React, { Component } from 'react'; import { OTA_SETTINGS_ENDPOINT } from '../constants/Endpoints'; import {withNotifier} from '../components/SnackbarNotification'; import SectionContent from '../components/SectionContent'; import OTASettingsForm from '../forms/OTASettingsForm'; import { simpleGet } from '../helpers/SimpleGet'; import { simplePost } from '../helpers/SimplePost'; class OTASettings extends Component { constructor(props) { super(props); this.state = { otaSettings:null, otaSettingsFetched: false, errorMessage:null }; this.setState = this.setState.bind(this); this.loadOTASettings = this.loadOTASettings.bind(this); this.saveOTASettings = this.saveOTASettings.bind(this); } componentDidMount() { this.loadOTASettings(); } loadOTASettings() { simpleGet( OTA_SETTINGS_ENDPOINT, this.setState, this.props.raiseNotification, "otaSettings", "otaSettingsFetched" ); } saveOTASettings(e) { simplePost( OTA_SETTINGS_ENDPOINT, this.state, this.setState, this.props.raiseNotification, "otaSettings", "otaSettingsFetched" ); } otaSettingValueChange = name => event => { const { otaSettings } = this.state; otaSettings[name] = event.target.value; this.setState({otaSettings}); }; otaSettingCheckboxChange = name => event => { const { otaSettings } = this.state; otaSettings[name] = event.target.checked; this.setState({otaSettings}); } render() { const { otaSettingsFetched, otaSettings, errorMessage } = this.state; return ( ) } } export default withNotifier(OTASettings);