File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -100,23 +100,22 @@ function startRound() {
100100}
101101
102102function 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}
You can’t perform that action at this time.
0 commit comments