-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Finishes #187354252] implementing profile page settings #53
Conversation
4f14099
to
6a11a93
Compare
6a11a93
to
70ce650
Compare
const constructUpdatedFields = (body: any, user: User, uploadedImage?: string) => { | ||
return { | ||
firstName: body.firstName || user.firstName, | ||
lastName: body.lastName || user.lastName, | ||
gender: body.gender || user.gender, | ||
phoneNumber: body.phoneNumber || user.phoneNumber, | ||
photoUrl: uploadedImage || user.photoUrl, | ||
}; | ||
}; | ||
|
||
// Function to construct user response | ||
const constructUserResponse = (user: User, updatedFields: any) => { | ||
return { | ||
id: user.id, | ||
firstName: updatedFields.firstName, | ||
lastName: updatedFields.lastName, | ||
email: user.email, | ||
phoneNumber: updatedFields.phoneNumber, | ||
gender: updatedFields.gender, | ||
photoUrl: updatedFields.photoUrl, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess these functions should be in helpers directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us leave it like that so far
const constructUpdatedFields = (body: any, user: User, uploadedImage?: string) => { | ||
return { | ||
firstName: body.firstName || user.firstName, | ||
lastName: body.lastName || user.lastName, | ||
gender: body.gender || user.gender, | ||
phoneNumber: body.phoneNumber || user.phoneNumber, | ||
photoUrl: uploadedImage || user.photoUrl, | ||
}; | ||
}; | ||
|
||
// Function to construct user response | ||
const constructUserResponse = (user: User, updatedFields: any) => { | ||
return { | ||
id: user.id, | ||
firstName: updatedFields.firstName, | ||
lastName: updatedFields.lastName, | ||
email: user.email, | ||
phoneNumber: updatedFields.phoneNumber, | ||
gender: updatedFields.gender, | ||
photoUrl: updatedFields.photoUrl, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us leave it like that so far
import { sendInternalErrorResponse } from '../validations'; | ||
|
||
export const getUserProfile = async (req: Request, res: Response): Promise<void> => { | ||
const userId: string = req.params.userId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello bruh,
It seems like you should fetch the user from the authenticated middleware rather than from the params.
}; | ||
}; | ||
|
||
export const updateUser = async (req: Request, res: Response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to check and validate the request body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems fine to me!
Purpose
This pull request aims to implement user profiles in the application to allow users to maintain their personal information.
Changes Made
Implemented user profile creation upon user registration.
Added fields for personal information such as name, email, gender, birthdate, language
Added fields for billing address.
Implemented profile editing functionality.
Associated a timestamp with each user profile.
Documented the feature using Swagger.
Testing Instructions
Register as a new user in the application.
Verify that upon registration, a user profile is created with the provided personal information.
Verify that you can edit your own profile but not another user's profile.
Ensure that a timestamp is associated with each profile creation.
Review the Swagger documentation to understand the profile endpoints and their usage.
Related Issues
no issues
Checklist
Please review the following checklist and make sure all tasks are complete before submitting: