Fixed bug related to new Vote struct, id and submit date can be None
(useful for posting new votes, ie without id and submit date)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
let vote = {
|
||||
submit_date: null,
|
||||
plus_player_id: null,
|
||||
plus_nickname: "",
|
||||
plus_reason: "",
|
||||
@@ -11,7 +12,7 @@ let current_page = 0;
|
||||
|
||||
async function main() {
|
||||
if (read_cookie()) {
|
||||
showMessage("Merci pour ton vote!", "Ton vote a bien été prit en compte.", false, "info");
|
||||
showMessage("Merci pour ton vote!", "Ton vote a bien été pris en compte.", false, "info");
|
||||
return;
|
||||
}
|
||||
let players = await fetch("/data/players").then(r => r.json());
|
||||
@@ -95,7 +96,6 @@ async function main() {
|
||||
method: "post", body: JSON.stringify(vote)
|
||||
})
|
||||
.then(r => r.status) === 200) {
|
||||
set_cookie();
|
||||
showMessage("Merci pour ton vote!", "Ton vote a bien été pris en compte.", false, "info");
|
||||
}
|
||||
console.log(vote);
|
||||
@@ -160,14 +160,6 @@ function showMessage(title, description, canBeDismissed, type) {
|
||||
})
|
||||
}
|
||||
|
||||
function set_cookie() {
|
||||
let date = new Date(Date.now());
|
||||
date.setDate(date.getDate() + 1);
|
||||
date.setHours(0, 0,0);
|
||||
console.log(date);
|
||||
document.cookie = `hasvoted=true; expires=${date.toUTCString()}; path=/`;
|
||||
}
|
||||
|
||||
function read_cookie() {
|
||||
return document.cookie.includes("hasvoted=true");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user