From 595e0b762773637639d3b778e785e5b1694fe5b6 Mon Sep 17 00:00:00 2001 From: Kshitij Kochhar Date: Thu, 3 Oct 2024 21:56:21 -0400 Subject: [PATCH 1/4] [feat] display points --- src/pages/users/[user].jsx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/pages/users/[user].jsx b/src/pages/users/[user].jsx index 24ffb71d..7b6ab52e 100644 --- a/src/pages/users/[user].jsx +++ b/src/pages/users/[user].jsx @@ -1,3 +1,4 @@ + import Head from 'next/head'; import { useState, useEffect, useRef } from 'react'; import { Context } from '@/context'; @@ -153,6 +154,8 @@ export default function Create() { const [followerPage, setFollowerPage] = useState(0); // Initial page const [totalFollowerPages, setTotalFollowerPages] = useState(0); // Total pages + const [points, setPoints] = useState(0); + const [following, setFollowing] = useState(0); const [followingPage, setFollowingPage] = useState(0); // Initial page const [totalFollowingPages, setTotalFollowingPages] = useState(0); // Total pages @@ -683,6 +686,30 @@ export default function Create() { } }, [user, followingPage]); + + useEffect(() => { + const fetchUserPoints = async () => { + try { + const endPoint = `${process.env.NEXT_PUBLIC_API_URL}/users/${user.username}/points`; + console.log('Fetching user points:', endPoint); + + const response = await request(endPoint, 'GET'); + if (response && response.totalPoints) { + setPoints(response.totalPoints); + console.log('User points:', response.totalPoints); + } + throw new Error('Failed to fetch user points'); + } catch (error) { + console.error('Failed to fetch user points:', error); + } + }; + + if (user && user.username) { + fetchUserPoints(); + } + }, [user]); + + const userData = { user, ownUser: true }; // Follower @@ -967,6 +994,13 @@ export default function Create() { )}

+ + {user && points && ( + + Points: {points} + + )} + {' '} {(user && user.location) || ( Date: Thu, 3 Oct 2024 22:00:54 -0400 Subject: [PATCH 2/4] [feat] minor bug fix --- src/pages/users/[user].jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/users/[user].jsx b/src/pages/users/[user].jsx index 7b6ab52e..759c886c 100644 --- a/src/pages/users/[user].jsx +++ b/src/pages/users/[user].jsx @@ -154,7 +154,7 @@ export default function Create() { const [followerPage, setFollowerPage] = useState(0); // Initial page const [totalFollowerPages, setTotalFollowerPages] = useState(0); // Total pages - const [points, setPoints] = useState(0); + const [points, setPoints] = useState("0"); const [following, setFollowing] = useState(0); const [followingPage, setFollowingPage] = useState(0); // Initial page From 3f1fcef1529ba3a194430eac2fb13f32b39e38fe Mon Sep 17 00:00:00 2001 From: Pranav Ramesh Date: Tue, 12 Nov 2024 02:15:11 -0500 Subject: [PATCH 3/4] feat: update recovery UI/UX to be consistent with register + login --- src/pages/forgot-password.jsx | 57 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/pages/forgot-password.jsx b/src/pages/forgot-password.jsx index a373d049..5dc98b87 100644 --- a/src/pages/forgot-password.jsx +++ b/src/pages/forgot-password.jsx @@ -4,7 +4,7 @@ import { ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; // Import useRouter - +import AuthFooter from '@/components/auth/AuthFooter' export default function Forgot() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); @@ -131,26 +131,12 @@ export default function Forgot() { style={{ fontFamily: 'Poppins, sans-serif' }} className="flex min-h-full flex-col justify-center py-12 sm:px-6 lg:px-8" > -

- - CTFGuide - -

- Forgot your password? -

-

- No worries - we'll get you back to your account in no time. -

-
+
+

Update your credentials

+ +
@@ -204,18 +192,23 @@ export default function Forgot() { type="password" onChange={(e) => setConfirmPassword(e.target.value)} required - className="block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 text-white placeholder-gray-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500 sm:text-sm" + className="block w-full appearance-none border border-gray-300 px-3 py-2 text-white placeholder-gray-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500 sm:text-sm" />
- +
:
+
+ +

Account Recovery

+

No worries - we'll get you back to your account in no time.

+
@@ -228,7 +221,7 @@ export default function Forgot() { onChange={(e) => setEmail(e.target.value)} autoComplete="email" required - className="block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 text-white placeholder-gray-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500 sm:text-sm" + className="block w-full appearance-none border border-gray-300 px-3 py-2 text-white placeholder-gray-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500 sm:text-sm" />
@@ -240,7 +233,7 @@ export default function Forgot() { @@ -250,22 +243,28 @@ export default function Forgot() {
} - -
-← Return to login? +
+Return to login?
+ + + + + + + Date: Tue, 12 Nov 2024 02:25:05 -0500 Subject: [PATCH 4/4] fix: if you have pro, our own sponsor messaging will no longer show up on dashboard --- src/pages/dashboard.jsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/pages/dashboard.jsx b/src/pages/dashboard.jsx index e3f489b5..bd79e0bd 100644 --- a/src/pages/dashboard.jsx +++ b/src/pages/dashboard.jsx @@ -32,7 +32,7 @@ export default function Dashboard() { const [loading, setLoading] = useState(false); const [showOnboarding, setShowOnboarding] = useState(false); const [showUpgradeModal, setShowUpgradeModal] = useState(false); - + const [role, setRole] = useState(false); const exampleObjectives = [ { completed: false, @@ -114,9 +114,21 @@ export default function Dashboard() { } }; + const fetchAccountDetails = async() => { + request(`${process.env.NEXT_PUBLIC_API_URL}/account`, 'GET', null) + .then((data) => { + + setRole(data.role); + }) + .catch((err) => { + console.log(err); + }); + } + fetchRecommendedChallenges(); fetchPopularChallenges(); + fetchAccountDetails(); request(`${process.env.NEXT_PUBLIC_API_URL}/activityFeed/`, 'GET', null).then(response => { console.log(response) setActivities(response.activityFeed); @@ -274,10 +286,13 @@ export default function Dashboard() { - + +
-

+ { role == "USER" && +
+

Sponsor Messaging

- -

+

+} +

Connect with CTFGuide