From aa4a20eda2d17e5d62f21f68bf12be54268c2f53 Mon Sep 17 00:00:00 2001 From: AbhiByreddy <54539671+ThunderBird260@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:21:52 -0400 Subject: [PATCH 1/4] feat: added moderation notifications, connected all user action buttons in moderation panel --- src/pages/moderation.jsx | 74 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/src/pages/moderation.jsx b/src/pages/moderation.jsx index 34abc996..464dd8a5 100644 --- a/src/pages/moderation.jsx +++ b/src/pages/moderation.jsx @@ -46,6 +46,11 @@ export default function Competitions() { }); }; + const resetFields = () => { + document.getElementById('usernameInput').value = ""; + document.getElementById('reasonInput').value = ""; + }; + const fetchPendingChallenges = async () => { try { const response = await request(process.env.NEXT_PUBLIC_API_URL + '/pending', "GET"); @@ -73,7 +78,8 @@ export default function Competitions() { const handleResetPFP = async () => { const username = document.getElementById('usernameInput').value; - const reason = ""; // Set reason as blank for now + const reason = document.getElementById('reasonInput').value; + console.log('REASON: ', reason); if (!username) { alert("Please enter a username."); @@ -87,6 +93,9 @@ export default function Competitions() { } else { alert("Failed to reset profile picture."); } + + resetFields(); + } catch (error) { console.error(error); alert("An error occurred while resetting the profile picture."); @@ -95,7 +104,7 @@ export default function Competitions() { const handleResetBanner = async () => { const username = document.getElementById('usernameInput').value; - const reason = ""; // Set reason as blank for now + const reason = document.getElementById('reasonInput').value; if(!username) { alert("Please enter a username."); @@ -108,6 +117,9 @@ export default function Competitions() { }else { alert("Failed to reset banner."); } + + resetFields(); + }catch(err){ console.log(err); alert("An error occurred while resetting the banner."); @@ -116,7 +128,7 @@ export default function Competitions() { const handleDisableAccount = async () => { const username = document.getElementById('usernameInput').value; - const reason = ""; + const reason = document.getElementById('reasonInput').value; if (!username) { alert("Please enter a username."); @@ -130,15 +142,41 @@ export default function Competitions() { } else { alert("Failed to disable account."); } + + resetFields(); + }catch(err){ console.log(err); alert("An error occurred while disabling the account."); } }; + const handleResetBio = async () => { + + const username = document.getElementById('usernameInput').value; + const reason = document.getElementById('reasonInput').value; + + if (!username) { + alert("Please enter a username."); + return; + } + try{ + const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/${username}/resetBio`, "POST", {reason}); + if(response.success){ + alert("Bio reset successfully!"); + }else{ + alert("Failed to reset bio."); + } + + resetFields(); + }catch(err){ + console.log(err); + alert("An error occurred while resetting the bio."); + } + }; const handleEnableAccount = async () => { const username = document.getElementById('usernameInput').value; - const reason = ""; + const reason = document.getElementById('reasonInput').value; if (!username) { alert("Please enter a username."); @@ -151,12 +189,37 @@ export default function Competitions() { }else { alert("Failed to enable account."); } + + resetFields(); }catch(err){ console.log(err); alert("An error occurred while enabling the account."); } }; + const handleWarnUser = async () => { + const username = document.getElementById('usernameInput').value; + const reason = document.getElementById('reasonInput').value; + + if (!username) { + alert("Please enter a username."); + return; + } + try{ + const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/${username}/warnUser`, "POST", {reason}); + if(response.success){ + alert("User warned successfully!"); + }else { + alert("Failed to warn user."); + } + + resetFields(); + }catch(err){ + console.log(err); + alert("An error occurred while warning the user."); + } + }; + return ( <>
@@ -192,9 +255,10 @@ export default function Competitions() { - + + From d0394b25bcc96b3c7b10a3e5f6814787168e35c5 Mon Sep 17 00:00:00 2001 From: AbhiByreddy <54539671+ThunderBird260@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:28:44 -0400 Subject: [PATCH 2/4] feat: button in moderation to manually resync leaderboard --- src/pages/moderation.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pages/moderation.jsx b/src/pages/moderation.jsx index 464dd8a5..30389a1a 100644 --- a/src/pages/moderation.jsx +++ b/src/pages/moderation.jsx @@ -72,6 +72,20 @@ export default function Competitions() { } }; + const handleResyncLeaderboard = async () => { + try{ + const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/syncLeaderboard`, "POST"); + if(response.success){ + alert("Leaderboard resynced successfully!"); + }else { + alert("Failed to resync leaderboard."); + } + }catch(err){ + console.log(err); + alert("An error occurred while resyncing the leaderboard."); + } + }; + useEffect(() => { fetchPendingChallenges(); }, []); @@ -260,6 +274,7 @@ export default function Competitions() { + @@ -269,6 +284,7 @@ export default function Competitions() { +