Skip to content

Commit e674ba1

Browse files
Update app.js
1 parent aee82e6 commit e674ba1

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

app.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,22 @@ function startRound() {
100100
}
101101

102102
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", {
103+
fetch("https://your-backend.glitch.me/report-troll", {
107104
method: "POST",
108-
headers: { "Content-Type": "application/json" },
109-
body: JSON.stringify({ reporterId: user.uid })
105+
headers: {
106+
"Content-Type": "application/json"
107+
},
108+
body: JSON.stringify({ reporterId: user.uid }) // must be the current user's UID
110109
})
111110
.then(res => res.json())
112111
.then(data => {
113112
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";
113+
alert("Opponent reported. You have a new game link.");
118114
} else {
119-
alert("Failed to create new game.");
115+
alert("Something went wrong reporting the opponent.");
120116
}
121-
});
117+
})
118+
.catch(err => {
119+
console.error("Error reporting opponent:", err);
120+
});
122121
}

0 commit comments

Comments
 (0)