From 7defe45b122784b64a6e53d7f433b61f8166206d Mon Sep 17 00:00:00 2001
From: AbhiByreddy <54539671+ThunderBird260@users.noreply.github.com>
Date: Wed, 31 Jul 2024 14:04:05 -0400
Subject: [PATCH 1/3] feat: solved challenges now use scores
---
src/components/profile/v2/SolvedChallenges.jsx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/components/profile/v2/SolvedChallenges.jsx b/src/components/profile/v2/SolvedChallenges.jsx
index d60029d9..2708f6c5 100644
--- a/src/components/profile/v2/SolvedChallenges.jsx
+++ b/src/components/profile/v2/SolvedChallenges.jsx
@@ -17,11 +17,11 @@ const SolvedChallenges = ({ user }) => {
setSolvedChallenges(response);
setLoading(false);
-
};
setLoading(true);
fetchSolvedChallenges();
+
}, [user]);
if (loading) return
{solvedChallenges.map(challenge => (
{
- router.push(`/challenges/${challenge.id}`);
- }} className='mt-2 hover:bg-neutral-700/40 cursor-pointer list-none text-center text-white flex bg-neutral-700/50 px-4 py-4' key={challenge.id}>
+ router.push(`/challenges/${challenge.challenge.id}`);
+ }} className='mt-2 hover:bg-neutral-700/40 cursor-pointer list-none text-center text-white flex bg-neutral-700/50 px-4 py-4' key={challenge.challenge.id}>
- {challenge.title}
+ {challenge.challenge.title}
- {challenge.difficulty} {challenge.category}
+ {challenge.challenge.difficulty} {challenge.challenge.category}
- {challenge.upvotes}
- {challenge.downvotes}
+ {challenge.challenge.upvotes}
+ {challenge.challenge.downvotes}
From 71016fe0078c929b24849259eb84a41edc93ffa2 Mon Sep 17 00:00:00 2001
From: AbhiByreddy <54539671+ThunderBird260@users.noreply.github.com>
Date: Wed, 31 Jul 2024 16:10:22 -0400
Subject: [PATCH 2/3] feat: resetting banners in moderation
---
src/pages/moderation.jsx | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/pages/moderation.jsx b/src/pages/moderation.jsx
index 71df74b0..89c9eae1 100644
--- a/src/pages/moderation.jsx
+++ b/src/pages/moderation.jsx
@@ -93,6 +93,27 @@ export default function Competitions() {
}
};
+ const handleResetBanner = async () => {
+ const username = document.getElementById('usernameInput').value;
+ const reason = ""; // Set reason as blank for now
+
+ if(!username) {
+ alert("Please enter a username.");
+ return;
+ }
+ try{
+ const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/${username}/resetBanner`, "POST", {reason});
+ if(response.success){
+ alert("Banner reset successfully!");
+ }else {
+ alert("Failed to reset banner.");
+ }
+ }catch(err){
+ console.log(err);
+ alert("An error occurred while resetting the banner.");
+ }
+ };
+
return (
<>
@@ -129,7 +150,7 @@ export default function Competitions() {
-
+
From d3d522053319d48b6ca3ecbde3b6c3835bccdc13 Mon Sep 17 00:00:00 2001
From: AbhiByreddy <54539671+ThunderBird260@users.noreply.github.com>
Date: Wed, 31 Jul 2024 16:23:38 -0400
Subject: [PATCH 3/3] feat: banning and unbanning accounts on moderation
---
src/pages/moderation.jsx | 46 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/pages/moderation.jsx b/src/pages/moderation.jsx
index 89c9eae1..34abc996 100644
--- a/src/pages/moderation.jsx
+++ b/src/pages/moderation.jsx
@@ -114,6 +114,49 @@ export default function Competitions() {
}
};
+ const handleDisableAccount = async () => {
+ const username = document.getElementById('usernameInput').value;
+ const reason = "";
+
+ if (!username) {
+ alert("Please enter a username.");
+ return;
+ }
+
+ try {
+ const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/${username}/disableAccount`, "POST", { reason });
+ if (response.success) {
+ alert("Account disabled successfully!");
+ } else {
+ alert("Failed to disable account.");
+ }
+ }catch(err){
+ console.log(err);
+ alert("An error occurred while disabling the account.");
+ }
+ };
+
+ const handleEnableAccount = async () => {
+ const username = document.getElementById('usernameInput').value;
+ const reason = "";
+
+ if (!username) {
+ alert("Please enter a username.");
+ return;
+ }
+ try{
+ const response = await request(`${process.env.NEXT_PUBLIC_API_URL}/admin/${username}/enableAccount`, "POST", {reason});
+ if(response.success){
+ alert("Account enabled successfully!");
+ }else {
+ alert("Failed to enable account.");
+ }
+ }catch(err){
+ console.log(err);
+ alert("An error occurred while enabling the account.");
+ }
+ };
+
return (
<>
@@ -147,7 +190,8 @@ export default function Competitions() {
USER ACTIONS
-
+
+