This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
atsebay.t/ui/src/lib/grades.js

32 lines
676 B
JavaScript

export class Grade {
constructor(res) {
if (res) {
this.update(res);
}
}
update({ id, login, id_user, id_work, date, score, comment }) {
this.id = id;
this.login = login;
this.id_user = id_user;
this.id_work = id_work;
this.date = date;
this.score = score;
this.comment = comment;
}
async delete() {
if (this.id) {
const res = await fetch(`api/works/${this.id_work}/grades/${this.id}`, {
method: 'DELETE',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return true;
} else {
throw new Error((await res.json()).errmsg);
}
}
}
}