fix user profile name update
This commit is contained in:
parent
52ba0aea42
commit
17c4092a83
@ -118,12 +118,24 @@ func (p *UserProcessorImpl) UpdateUser(ctx context.Context, id uuid.UUID, req *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
updated := transformer.UpdateUserEntity(existingUser, req)
|
updated := transformer.UpdateUserEntity(existingUser, req)
|
||||||
|
fmt.Printf("Test Updated: %+v\n", updated)
|
||||||
|
|
||||||
err = p.userRepo.Update(ctx, updated)
|
err = p.userRepo.Update(ctx, updated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to update user: %w", err)
|
return nil, fmt.Errorf("failed to update user: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.Name != nil) {
|
||||||
|
profile, err := p.profileRepo.GetByUserID(ctx, updated.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get user profile: %w", err)
|
||||||
|
}
|
||||||
|
profile.FullName = *req.Name
|
||||||
|
if err := p.profileRepo.Update(ctx, profile); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to update user profile: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update departments if provided
|
// Update departments if provided
|
||||||
if req.DepartmentIDs != nil {
|
if req.DepartmentIDs != nil {
|
||||||
departments := make([]entities.Department, len(*req.DepartmentIDs))
|
departments := make([]entities.Department, len(*req.DepartmentIDs))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user