You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
446 B
TypeScript

import { Controller } from "stimulus";
export default class TaskController extends Controller {
id: string;
connect() {
this.id = this.element.attributes["data-id"].value;
}
async toggle(event: Event) {
await fetch(`/api/v1/collections/tasks/${this.id}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
done: (event.target as HTMLInputElement).checked,
}),
});
}
}