Skip to content

Commit

Permalink
Refactor profile update logic to use a single updateData object
Browse files Browse the repository at this point in the history
  • Loading branch information
mayura-andrew committed Sep 9, 2024
1 parent e1ef71e commit 20f0de5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/services/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ export const updateProfile = async (
try {
const profileRepository = dataSource.getRepository(Profile)

const updatedFields: Partial<Profile> = {}
const { primary_email, first_name, last_name, image_url } = updateData

if (updateData.primary_email)
updatedFields.primary_email = updateData.primary_email
if (updateData.first_name) updatedFields.first_name = updateData.first_name
if (updateData.last_name) updatedFields.last_name = updateData.last_name
if (updateData.image_url) updatedFields.image_url = updateData.image_url
const updatedFields: Partial<Profile> = {
primary_email,
first_name,
last_name,
image_url
}

await profileRepository.update(
{ uuid: user.uuid },
Expand Down

0 comments on commit 20f0de5

Please sign in to comment.