Skip to content
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

Merged
merged 1 commit into from
May 9, 2024

Conversation

hatfelicien
Copy link
Contributor

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:

  • Code follows the project's coding standards
  • Changes are covered by tests
  • Documentation is updated (if applicable)
  • All tests pass

@hatfelicien hatfelicien force-pushed the 187354252-ft-profile-page-settings branch 2 times, most recently from 4f14099 to 6a11a93 Compare May 8, 2024 06:47
@hatfelicien hatfelicien force-pushed the 187354252-ft-profile-page-settings branch from 6a11a93 to 70ce650 Compare May 8, 2024 07:50
Comment on lines +33 to +54
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,
};
};
Copy link
Collaborator

@patrickhag patrickhag May 8, 2024

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

Copy link
Collaborator

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

Comment on lines +33 to +54
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,
};
};
Copy link
Collaborator

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;
Copy link
Collaborator

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) => {
Copy link
Collaborator

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.

Copy link
Collaborator

@Favor-star Favor-star left a 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!

@niyontwali niyontwali merged commit d6fbc67 into develop May 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants