import { h, Component } from 'preact'; import Trigger from './trigger'; import Condition from '../common/component/condition'; import Script from '../common/component/script'; export default class Automation extends Component { constructor() { super(); this.onChange = this.onChange.bind(this); this.triggerChanged = this.triggerChanged.bind(this); this.conditionChanged = this.conditionChanged.bind(this); this.actionChanged = this.actionChanged.bind(this); } onChange(ev) { this.props.onChange({ ...this.props.automation, [ev.target.name]: ev.target.value, }); } triggerChanged(trigger) { this.props.onChange({ ...this.props.automation, trigger, }); } conditionChanged(condition) { this.props.onChange({ ...this.props.automation, condition, }); } actionChanged(action) { this.props.onChange({ ...this.props.automation, action, }); } render({ automation, isWide }) { const { alias, trigger, condition, action } = automation; return (