From ef17dfe8f664f65a1777ada164ee82aac3370c41 Mon Sep 17 00:00:00 2001 From: Syed Hisham Akmal Date: Sat, 21 Oct 2023 18:17:11 +0530 Subject: [PATCH 1/5] Returning a user not found message --- src/component/Profile/profilePage.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/component/Profile/profilePage.jsx b/src/component/Profile/profilePage.jsx index adb1e12..af47572 100644 --- a/src/component/Profile/profilePage.jsx +++ b/src/component/Profile/profilePage.jsx @@ -63,6 +63,7 @@ function ProfilePage() { }, [ifedit]); useEffect(() => { + console.log(profile) if (accessProfile) { setFollower(profile.followers.length); setFollowing(profile.following.length); @@ -182,6 +183,16 @@ function ProfilePage() { return formattedDate; } + if(Object.keys(profile).length === 0) return ( + <> + +
+

User @{apiname} not found :(

+
+ + ) + + return ( <> From e52a693224b738b3608fc0cc01970883f2bbd83c Mon Sep 17 00:00:00 2001 From: Syed Hisham Akmal Date: Sat, 21 Oct 2023 18:57:01 +0530 Subject: [PATCH 2/5] Returning a user not found message --- src/component/Profile/profilePage.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/component/Profile/profilePage.jsx b/src/component/Profile/profilePage.jsx index af47572..10c503d 100644 --- a/src/component/Profile/profilePage.jsx +++ b/src/component/Profile/profilePage.jsx @@ -63,7 +63,7 @@ function ProfilePage() { }, [ifedit]); useEffect(() => { - console.log(profile) + console.log(profile, accessProfile) if (accessProfile) { setFollower(profile.followers.length); setFollowing(profile.following.length); @@ -83,7 +83,7 @@ function ProfilePage() { useEffect(() => { // When the component mounts, call showTweets to display the tweets - showTweets(); + if(accessProfile) showTweets(); dispatch(ProfileAction(apiname)); }, [apiname]); @@ -183,10 +183,10 @@ function ProfilePage() { return formattedDate; } - if(Object.keys(profile).length === 0) return ( + if(!accessProfile) return ( <> -
+

User @{apiname} not found :(

From 483a75c511870e0f8b8194a16b5bc089e6326031 Mon Sep 17 00:00:00 2001 From: Syed Hisham Akmal Date: Sat, 21 Oct 2023 19:03:53 +0530 Subject: [PATCH 3/5] Enhancing the page --- src/component/Profile/profilePage.jsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/component/Profile/profilePage.jsx b/src/component/Profile/profilePage.jsx index 10c503d..adefe6c 100644 --- a/src/component/Profile/profilePage.jsx +++ b/src/component/Profile/profilePage.jsx @@ -186,9 +186,16 @@ function ProfilePage() { if(!accessProfile) return ( <> -
-

User @{apiname} not found :(

-
+
+
+ Avatar +
+
+ User @{apiname} not found ☹️ +
+
+
+
) From 7e1a9a82dfff56c011a3acf5c6646b136b5cdc7d Mon Sep 17 00:00:00 2001 From: Syed Hisham Akmal Date: Sat, 21 Oct 2023 20:13:56 +0530 Subject: [PATCH 4/5] Included loading and enhanced experience --- src/component/Profile/profilePage.css | 5 +++++ src/component/Profile/profilePage.jsx | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/component/Profile/profilePage.css b/src/component/Profile/profilePage.css index 604fa33..def79f3 100644 --- a/src/component/Profile/profilePage.css +++ b/src/component/Profile/profilePage.css @@ -1146,3 +1146,8 @@ font-size: 0.9rem; width: 78vw; } } + +.not-found{ + color: rgb(71, 200, 122, 0.9); + text-align: center; +} \ No newline at end of file diff --git a/src/component/Profile/profilePage.jsx b/src/component/Profile/profilePage.jsx index adefe6c..f72f017 100644 --- a/src/component/Profile/profilePage.jsx +++ b/src/component/Profile/profilePage.jsx @@ -63,7 +63,6 @@ function ProfilePage() { }, [ifedit]); useEffect(() => { - console.log(profile, accessProfile) if (accessProfile) { setFollower(profile.followers.length); setFollowing(profile.following.length); @@ -186,16 +185,16 @@ function ProfilePage() { if(!accessProfile) return ( <> -
+ {loading === true ? :
Avatar
- User @{apiname} not found ☹️ +

User @{apiname} not found ☹️

-
+
} ) From 854f5a92fbc04eb61ce39ecacc09caac0c4ebad0 Mon Sep 17 00:00:00 2001 From: Syed Hisham Akmal Date: Sat, 21 Oct 2023 20:22:09 +0530 Subject: [PATCH 5/5] Added comments to make code more readable --- src/component/Profile/profilePage.css | 2 ++ src/component/Profile/profilePage.jsx | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/component/Profile/profilePage.css b/src/component/Profile/profilePage.css index def79f3..2e8265c 100644 --- a/src/component/Profile/profilePage.css +++ b/src/component/Profile/profilePage.css @@ -1147,6 +1147,8 @@ font-size: 0.9rem; } } + +/* Used to display user not found message */ .not-found{ color: rgb(71, 200, 122, 0.9); text-align: center; diff --git a/src/component/Profile/profilePage.jsx b/src/component/Profile/profilePage.jsx index f72f017..419898e 100644 --- a/src/component/Profile/profilePage.jsx +++ b/src/component/Profile/profilePage.jsx @@ -82,6 +82,8 @@ function ProfilePage() { useEffect(() => { // When the component mounts, call showTweets to display the tweets + + //ensuring that tweets arent shown when the user doesnt exist(could lead to errors and hence the if condition) if(accessProfile) showTweets(); dispatch(ProfileAction(apiname)); }, [apiname]); @@ -182,6 +184,7 @@ function ProfilePage() { return formattedDate; } + /* Used to display user not found message */ if(!accessProfile) return ( <>