Skip to content

Commit aee82e6

Browse files
Update app.js
1 parent 34d77cd commit aee82e6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,26 @@ function startRound() {
9797
fetch("https://year8-chess-tournament-backend.glitch.me/start-round", { method: "POST" })
9898
.then(res => res.json())
9999
.then(data => alert(`Started new round with ${data.pairings} games.`));
100+
}
101+
102+
function reportTroll() {
103+
const user = firebase.auth().currentUser;
104+
if (!user) return alert("Please sign in first.");
105+
106+
fetch("https://year8-chess-tournament-backend.glitch.me/report-troll", {
107+
method: "POST",
108+
headers: { "Content-Type": "application/json" },
109+
body: JSON.stringify({ reporterId: user.uid })
110+
})
111+
.then(res => res.json())
112+
.then(data => {
113+
if (data.success) {
114+
alert("New game created due to trolling.");
115+
const gameLink = document.getElementById("game-link");
116+
gameLink.href = data.newGameUrl;
117+
gameLink.innerText = "Join New Game";
118+
} else {
119+
alert("Failed to create new game.");
120+
}
121+
});
100122
}

0 commit comments

Comments
 (0)