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.

24 lines
440 B
TypeScript

import { Controller } from "stimulus";
window;
export default class 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,
}),
});
}
}