Skip to content

Commit 2cc66f3

Browse files
committed
feat: moderation unapproval of challenges
1 parent bb556ea commit 2cc66f3

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/pages/moderation.jsx

+24-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@ export default function Competitions() {
9595

9696
};
9797

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+
98121
const handleResyncLeaderboard = async () => {
99122
try{
100123
const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/syncLeaderboard`, "POST");
@@ -306,7 +329,7 @@ export default function Competitions() {
306329
<input type="text" placeholder='Enter CHALLENGE ID' className='mb-2 text-white bg-neutral-800 border-none w-full' id = "challengeIdInput"></input>
307330
<textarea placeholder='Reason' className='mb-2 text-white bg-neutral-800 border-none w-full' id ="challengeReasonInput"></textarea>
308331
<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>
310333
<button className='ml-2 px-2 py-1 bg-red-600 text-white mt-2' onClick={handleResyncLeaderboard}>Resync Leaderboard</button>
311334
</div>
312335
</div>

0 commit comments

Comments
 (0)