dyno-bot/Dyno-web-premium-before-reset/react/dashboard/common/SettingCheckbox.jsx
2020-09-12 19:08:48 +01:00

19 lines
563 B
JavaScript

import React from 'react';
import RichCheckbox from './RichCheckbox.jsx';
import { updateModuleSetting } from '../service/dashboardService.js';
export default class SettingCheckbox extends RichCheckbox {
constructor() {
super();
this.onChange = this.onChange.bind(this);
}
async onChange() {
this.setState({ isEnabled: !this.state.isEnabled });
updateModuleSetting(this.props.module, this.props.setting, !this.state.isEnabled, this.props.friendlyName);
if (this.props.onChange) {
this.props.onChange(this.props, !this.state.isEnabled);
}
}
}