From 7a486d9bce599b3dc4f23cfa0ad56a1a31fb785b Mon Sep 17 00:00:00 2001 From: Kshitij Kochhar Date: Mon, 12 Aug 2024 15:18:13 -0400 Subject: [PATCH 1/2] [feat] follow/unfollow and following/followers buttons are more intuitive and responsive --- src/pages/users/[user].jsx | 42 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/pages/users/[user].jsx b/src/pages/users/[user].jsx index f2b5d773..24ffb71d 100644 --- a/src/pages/users/[user].jsx +++ b/src/pages/users/[user].jsx @@ -944,20 +944,26 @@ export default function Create() { )} {!ownUser && followedUser && ( - - + - + {' '} + Unfollow + )} {!ownUser && !followedUser && ( - - + - + {' '} + Follow + )}

@@ -976,21 +982,25 @@ export default function Create() { {user && ( <> setDisplayMode('followers')} > - {' '} Followers - {' '} + {' '} {followerNum || '0'} + setDisplayMode('following')} > - {' '} Following - {' '} + {' '} {followingNum || '0'} + )}

From 002cad69ab6f88f1f78279ed631798b9fdf634a3 Mon Sep 17 00:00:00 2001 From: Stephen Stefanatos Date: Thu, 15 Aug 2024 16:13:53 -0400 Subject: [PATCH 2/2] Rerouting to login after unauth --- src/pages/_app.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index 9c93ebc3..359c4351 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -7,6 +7,8 @@ import { Context } from '../context'; import { useEffect, useState } from 'react'; import request from '@/utils/request'; import { Analytics } from "@vercel/analytics/react" +import { usePathname, useRouter } from 'next/navigation'; + export default function App({ Component, pageProps }) { const [username, setUsername] = useState(''); @@ -14,6 +16,8 @@ export default function App({ Component, pageProps }) { const [accountType, setAccountType] = useState(''); const [profilePic, setProfilePic] = useState(''); const [points, setPoints] = useState(0); + const path = usePathname(); + const router = useRouter(); const appState = { role, setRole, @@ -26,7 +30,14 @@ export default function App({ Component, pageProps }) { const fetchUser = async () => { const url = process.env.NEXT_PUBLIC_API_URL + "/account"; const user = await request(url, "GET", null); - console.log(user); + + if(user && user.error && user.error === "Not authorized") { + const pathNames = ["/", "/login", "/careers", "/register", + "/onboarding", "/forgot-password", "/education", "/userrs", + "/privacy-policy","/404", "/terms-of-service", "/learn"]; + if(!pathNames.includes(path)) router.push("/login"); + } + if (user && user.username) { setRole(user.role); setUsername(user.username);