The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

68 lines
1.8 KiB

const {query} = require("../client")
class Chapter {
/**
* @param {string} id
* @param {string} title
* @param {string} author
* @param {string} source
* @param {string | Date} createdDate
* @param {string | Date} fictionalDate
* @param {string | Date} editedDate
*/
constructor(id, title, author, source, createdDate, fictionalDate, editedDate) {
this.id = id
this.title = title
this.author = author
this.source = source
this.createdDate = new Date(createdDate)
this.fictionalDate = fictionalDate != null ? new Date(fictionalDate) : null
this.editedDate = new Date(editedDate)
}
}
const chapterApi = {
/**
* Call `editChapter(input)` mutation
*
* @param {{id:string, title:string, fictionalDate:Date, source: string}} input
* @returns {Promise<{title:string, fictionalDate:Date, source:string}>}
*/
editChapter(input) {
return query(`
mutation EditChapter($input: ChapterEditInput!) {
editChapter(input: $input) {
title
fictionalDate
source
}
}
`, {input}, {permissions: ["member", "story.edit"]}).then(({editChapter}) => {
if (editChapter.fictionalDate != null) {
editChapter.fictionalDate = new Date(editChapter.fictionalDate)
}
return editChapter
})
},
/**
* Call `removeChapter(input)` mutation
*
* @param {{id:string}} input
* @returns {Promise<{id: string}>}
*/
removeChapter(input) {
return query(`
mutation RemoveChapter($input: ChapterRemoveInput!) {
removeChapter(input: $input) {
id
}
}
`, {input}, {permissions: ["member", "story.edit"]}).then(({removeChapter}) => {
return removeChapter
})
},
}
module.exports = {Chapter, chapterApi}