Conversation
dburkhart07
left a comment
There was a problem hiding this comment.
Few small changes. Additionally, can we use this PR to update the user entity? If you notice, all the other fieldsin our entity have a name, type, and sometimes a few other things. Can we apply that to firstName, lastName, and email?
| @Put(':id/info') | ||
| async updateInfo( | ||
| @Param('id', ParseIntPipe) id: number, | ||
| @Body() updateUserInfo: updateUserInfo, |
There was a problem hiding this comment.
Thoughts on making this change here:
We already have an update user role, and are now maing an update info endpoint. Would we rather have two separate updates, or just abstract this updateUserInfo DTO to include the role as well. We could then make it so the update function just takes the DTO instead of a Partial (this seems weird, we dont do this anywhere else), and adjust both functions' logic.
There was a problem hiding this comment.
If we needed both endpoints I would suggest keeping them separate for the sake of letting any user type call this endpoint, but limiting the update role endpoint to admins. But now that we have combined standard and lead volunteers, there is no longer any use case for updating a user's role, so we should just remove that endpoint.
| ): Promise<User> { | ||
| const { firstName, lastName, phone } = updateUserInfo; | ||
|
|
||
| const updateData: Partial<User> = {}; |
There was a problem hiding this comment.
Due to Sam's comment above, can we just make it so tha usersService.update now just takings in an updateUserInfo DTO, and do all the parsing/checking if valid values in there? While we are at it, let's use this as an opportunity to write unit tests for that service function. Use the format in orders.service.spec.ts as a reference for how we should go about it, as well as the dummy data in the testing db for what you should expect as results.
ℹ️ Issue
Closes 102
📝 Description
Added an endpoint to update a user’s first name, last name, or phone number and tests for the controller to verify that it works.
✔️ Verification
Tested having no parameters, 2 parameters and 3 parameters and throwing the proper exceptions when having faulty data.
