add: polls
This commit is contained in:
parent
4dfa09207e
commit
6555324650
29 changed files with 339 additions and 56 deletions
|
@ -104,6 +104,35 @@
|
|||
});
|
||||
});
|
||||
|
||||
self.define("vote", async (_, id, option) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you want to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/posts/${id}/poll_vote`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
option,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
window.location.href = `/post/${id}`;
|
||||
});
|
||||
});
|
||||
|
||||
self.define("react", async (_, element, asset, asset_type, is_like) => {
|
||||
await trigger("atto::debounce", ["reactions::toggle"]);
|
||||
fetch("/api/v1/reactions", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue