Closed aryanp-86 closed 1 month ago
This pull request introduces changes across several files to enhance user profile management and data handling. The user.controller.js
file now includes a picture
property in the user response. The Avatar.jsx
component adds validation for the image source, defaulting to a placeholder if invalid. The ProfileTab.jsx
component updates the initial state to include the user's picture and improves the image upload handling. Additionally, authProvider.jsx
introduces new functions to decode HTML entities and process user data, ensuring the picture
property is correctly managed.
File Path | Change Summary |
---|---|
backend/src/controllers/user.controller.js | Added picture property to the response object in getCurrentUser function. |
frontend/src/components/Avatar/Avatar.jsx | Added validation for src prop; defaults to placeholder if invalid; minor formatting adjustments. |
frontend/src/scenes/settings/ProfileTab/ProfileTab.jsx | Updated formData to include user's picture; improved image upload handling and error logging. |
frontend/src/services/authProvider.jsx | Introduced decodeHtmlEntities and processUserData functions; updated authReducer to process user data. |
Objective | Addressed | Explanation |
---|---|---|
Close popup after updating image (#324) | ✅ | |
Prevent reverting to placeholder after refresh (#324) | ❌ | The implementation does not ensure the image persists after a refresh. |
picture
property to the user response in auth.controller.js
, aligning with the main PR's changes.picture
property.Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Closes #324
PR Title:
Fix Image Upload Popup Behavior and Placeholder Image Issue
Description:
This PR addresses the following issues related to the image upload popup and the rendering of the user's profile picture:
handleUploadImageModalClose()
function that is triggered after a successful image upload, closing the popup as expected.useEffect
inuseAuth
was not properly extracting thepicture
property from theuser
object, causinguserInfo
to miss the picture data on initial load. This PR includes modifications to ensure thepicture
string is extracted and set correctly withinuserInfo
.// Function to handle user data processing const processUserData = (userData) => { return { ...userData, picture: userData.picture ? decodeHtmlEntities(userData.picture) : null }; };
//Validation check so that picture string follows base64 constraints const validSrc = src && (src.startsWith('data:image') || src.startsWith('/') || src.startsWith('http')) ? src : '/vendetta.png';