refactor(page): extract handlers and utils into dedicated modules

This commit is contained in:
jessy-david-dev
2026-04-10 16:44:24 +02:00
parent 58d1a43a35
commit 4f6e793c74
3 changed files with 118 additions and 79 deletions
+23
View File
@@ -0,0 +1,23 @@
export function fmt(s: number): string {
const m = Math.floor(s / 60);
const sec = Math.floor(s % 60);
return `${m}:${String(sec).padStart(2, "0")}`;
}
export async function saveGame(data: {
mode: string;
startArticle: string;
targetArticle: string;
path: string[];
clicks: number;
timeSeconds: number;
won: boolean;
}) {
try {
await fetch("/api/games", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
});
} catch { /* silencieux — pas de compte ou hors ligne */ }
}