const moment = require("moment") const {channelApi} = require("../../../../../rpdata/api/Channel") module.exports = class { onCreate(input) { this.state = { error: null, loading: false, values: { name: "", locationName: "", eventName: "", logged: false, } } } change(key, ev) { this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value}) } open() { } close() { this.emit("close") } save() { if (this.state.loading) { return } const input = Object.assign({}, this.state.values) this.state.loading = true channelApi.add(input).then((res) => { this.emit("added", res) this.emit("close") }).catch(errs => { console.warn("Failed to add:", errs) this.state.error = "Failed to add: " + JSON.stringify(errs) }).then(() => { this.state.loading = false }) } }