mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 17:47:55 +00:00
update first and last name endpoint
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
UpdateNameDto,
|
||||
UpdateProfilePictureDataDto,
|
||||
UpdateRegionDataDto,
|
||||
UpdateTimezoneDataDto,
|
||||
@@ -167,6 +168,45 @@ export class UserService {
|
||||
throw new BadRequestException('Timezone update failed');
|
||||
}
|
||||
|
||||
return {
|
||||
uuid: updatedUser.uuid,
|
||||
firstName: updatedUser.firstName,
|
||||
lastName: updatedUser.lastName,
|
||||
profilePicture: updatedUser.profilePicture,
|
||||
region: updatedUser.region,
|
||||
timeZoneUuid: updatedUser.timeZone,
|
||||
};
|
||||
} catch (err) {
|
||||
throw new HttpException(
|
||||
err.message || 'User not found',
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
}
|
||||
async updateNameByUserUuid(userUuid: string, updateNameDto: UpdateNameDto) {
|
||||
try {
|
||||
const user = await this.getUserDetailsByUserUuid(userUuid);
|
||||
if (!user) {
|
||||
throw new HttpException('User not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!updateNameDto.firstName || !updateNameDto.lastName) {
|
||||
throw new BadRequestException('First Name and Last Name is required');
|
||||
}
|
||||
|
||||
await this.userRepository.update(
|
||||
{ uuid: userUuid },
|
||||
{
|
||||
firstName: updateNameDto.firstName,
|
||||
lastName: updateNameDto.lastName,
|
||||
},
|
||||
);
|
||||
|
||||
const updatedUser = await this.getUserDetailsByUserUuid(userUuid);
|
||||
if (!updatedUser.firstName || !updatedUser.lastName) {
|
||||
throw new BadRequestException('First Name and Last Name update failed');
|
||||
}
|
||||
|
||||
return {
|
||||
uuid: updatedUser.uuid,
|
||||
firstName: updatedUser.firstName,
|
||||
|
||||
Reference in New Issue
Block a user