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
; @@ -42,19 +42,19 @@ const SolvedChallenges = ({ user }) => {
{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}
diff --git a/src/pages/moderation.jsx b/src/pages/moderation.jsx index 71df74b0..34abc996 100644 --- a/src/pages/moderation.jsx +++ b/src/pages/moderation.jsx @@ -93,6 +93,70 @@ 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."); + } + }; + + 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 ( <> @@ -126,10 +190,11 @@ export default function Competitions() {

USER ACTIONS

- + + - +