add: go back button in rankings
All checks were successful
Deploy on push / deploy (push) Has been skipped

This commit is contained in:
2026-03-23 03:05:44 -07:00
parent dc1dce1120
commit ac52daa454
6 changed files with 426 additions and 50 deletions

View File

@@ -8,6 +8,7 @@ const {
loadRankingsState,
recordVote,
resetRankingsState,
undoLastRankingsVote,
} = require("./lib/rankings-state");
const DEFAULT_HOST = "127.0.0.1";
@@ -195,7 +196,17 @@ async function handleApiRequest(request, response, pathname, options) {
return true;
}
if (pathname === "/api/rankings" || pathname === "/api/rankings/vote" || pathname === "/api/rankings/reset") {
if (pathname === "/api/rankings/undo" && request.method === "POST") {
sendJson(response, 200, undoLastRankingsVote({ statePath: options.rankingsStatePath }));
return true;
}
if (
pathname === "/api/rankings" ||
pathname === "/api/rankings/vote" ||
pathname === "/api/rankings/reset" ||
pathname === "/api/rankings/undo"
) {
sendText(response, 405, "Method not allowed");
return true;
}