CredLock is a thriving haven for college students, fostering a supportive community that nurtures personal growth and academic excellence. Our mission is deeply rooted in empowering students through shared experiences and valuable educational resources.
Initially when the user navigated to the My Profile page, the follow button was rendered. This didn't make any sense as a user cannot follow himself/herself. Also clicking on the button resulted in an error message being shown as expected. This error message led to poor user experience.
This PR fixes this issue by modifying the My Profile page such that the follow button is not rendered when a user navigates to the My Profile page.
Description
To fix this issue i have made changes in CREDLOCKS/client/src/UserProfile.js
This react component is used in the My Profile page as well in viewing the profile of another user
Hence the follow button must render conditionally based on whether the its being used to view the profile of the currently logged in user or another user
This can easily be done by updating the code so that the follow button is only rendered if the username of current logged in user is not equal to the username of the user whose profile page is being seen.
the username of the profile being currently seen is given by variable username
the username of the currently logged in user is given by userDetails?.data.username
Why can we use usernames as unique identifier for users?
Under user.model.js username has been specified as a unique field
So different users will have different usernames
Hence we can use usernames as a unique identifier to compare whether the logged in user is same as that of user whose profile page is being seen.
Type of change
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
Motivation and Context
To improve user experience and avoid any confusion that may arise due to a follow button being displayed on My Profile page.
How Has This Been Tested?
The change made has been tested as follow:
Created a user by the name of John Doe
Created another user by the name of Jane Doe
Logged into Jane Doe's account
Navigated to Jane's My Profile page, where the follow button was not rendered as expected.
Navigated to John Doe's profile, where the follow button was rendered as expected.
This PR closes #8
Summary
Initially when the user navigated to the My Profile page, the follow button was rendered. This didn't make any sense as a user cannot follow himself/herself. Also clicking on the button resulted in an error message being shown as expected. This error message led to poor user experience.
This PR fixes this issue by modifying the My Profile page such that the follow button is not rendered when a user navigates to the My Profile page.
Description
CREDLOCKS/client/src/UserProfile.js
username
userDetails?.data.username
Why can we use usernames as unique identifier for users?
Type of change
Motivation and Context
To improve user experience and avoid any confusion that may arise due to a follow button being displayed on My Profile page.
How Has This Been Tested?
The change made has been tested as follow:
Screenshots:
BEFORE:
UI:
CODE:
AFTER:
UI:
CODE:
Checklist:
Test Configuration: