const moment = require("moment") const {storyApi} = require("../../../../../rpdata/api/Story") module.exports = class { onCreate(input) { this.state = { error: null, loading: false, values: { title: "", source: "", fictionalDate: "", }, } } onInput(input) { if (input.chapter && !this.first) { let {fictionalDate, title, source} = input.chapter if (fictionalDate != null) { fictionalDate = moment.utc(fictionalDate).format("MMM D, YYYY") } this.state.values = {fictionalDate, title, source} } } change(key, ev) { this.state.values[key] = ev.target.value } open() { } close() { this.emit("close") } doIt() { this.state.loading = true storyApi.remove({id: this.input.story.id}).then(() => { this.emit("remove") this.emit("close") }).catch(errs => { console.warn("Failed to delete:", errs) this.state.error = "Failed to delete: " + errs.message || errs[0].message }).then(() => { this.state.loading = false }) } }