File tree 1 file changed +24
-1
lines changed
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,29 @@ export default function Competitions() {
95
95
96
96
} ;
97
97
98
+ const handleUnapproveChallenge = async ( ) => {
99
+ const challengeId = document . getElementById ( 'challengeIdInput' ) . value ;
100
+ const reason = document . getElementById ( 'challengeReasonInput' ) . value ;
101
+
102
+ try {
103
+ const response = await request ( `${ process . env . NEXT_PUBLIC_API_URL } /admin/${ challengeId } /unapproveChallenge` , "POST" , { reason} ) ;
104
+ if ( response . success ) {
105
+ alert ( "Challenge unapproved successfully!" ) ;
106
+ } else {
107
+ alert ( "Failed to unapprove challenge." ) ;
108
+ }
109
+
110
+ document . getElementById ( 'challengeIdInput' ) . value = "" ;
111
+ document . getElementById ( 'challengeReasonInput' ) . value = "" ;
112
+
113
+
114
+ } catch ( err ) {
115
+ console . log ( err ) ;
116
+ alert ( "An error occurred while unapproving the challenge." ) ;
117
+ }
118
+
119
+ } ;
120
+
98
121
const handleResyncLeaderboard = async ( ) => {
99
122
try {
100
123
const response = await request ( `${ process . env . NEXT_PUBLIC_API_URL } /admin/syncLeaderboard` , "POST" ) ;
@@ -306,7 +329,7 @@ export default function Competitions() {
306
329
< input type = "text" placeholder = 'Enter CHALLENGE ID' className = 'mb-2 text-white bg-neutral-800 border-none w-full' id = "challengeIdInput" > </ input >
307
330
< textarea placeholder = 'Reason' className = 'mb-2 text-white bg-neutral-800 border-none w-full' id = "challengeReasonInput" > </ textarea >
308
331
< button className = 'ml-auto px-2 py-1 bg-red-600 text-white mt-2' onClick = { handleDeleteChallenge } > Delete Challenge</ button >
309
- < button className = 'ml-2 px-2 py-1 bg-yellow-600 text-white mt-2' > Unapprove Challenge</ button >
332
+ < button className = 'ml-2 px-2 py-1 bg-yellow-600 text-white mt-2' onClick = { handleUnapproveChallenge } > Unapprove Challenge</ button >
310
333
< button className = 'ml-2 px-2 py-1 bg-red-600 text-white mt-2' onClick = { handleResyncLeaderboard } > Resync Leaderboard</ button >
311
334
</ div >
312
335
</ div >
You can’t perform that action at this time.
0 commit comments