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:
2024-10-05 15:09:51 +02:00
parent 98dbcd11f1
commit 8a7c321044
3 changed files with 53 additions and 79 deletions

View File

@@ -11,7 +11,6 @@
<link rel="stylesheet" href="static/css/index.css">
</head>
<body>
<a href="/login" class="login" id="login">Se connecter</a>
<div id="app" class="app">
<h1 id="app_title">Vote +</h1>
<label for="player_id">Pour qui votes tu?</label>
@@ -37,5 +36,6 @@
<a href="/results">Résultats</a>
<a href="/archives">Archives</a>
</div>
<a href="/login" class="login" id="login">Se connecter</a>
</body>
</html>

View File

@@ -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");
}