dyno-bot/Dyno-web-premium-before-reset/react/dashboard/common/SettingCheckbox.jsx

19 lines
563 B
React
Raw Permalink Normal View History

2020-09-12 20:08:48 +02:00
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);
}
}
}