mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 10:46:17 +00:00
Update user relations and formatUserResponse method
This commit is contained in:
@ -110,7 +110,7 @@ export class ProjectUserService {
|
||||
'invitedBy',
|
||||
'isEnabled',
|
||||
],
|
||||
relations: ['roleType', 'spaces'],
|
||||
relations: ['roleType', 'spaces.space'],
|
||||
});
|
||||
if (!user) {
|
||||
user = await this.userRepository.findOne({
|
||||
@ -120,7 +120,7 @@ export class ProjectUserService {
|
||||
isActive: true,
|
||||
},
|
||||
select: ['uuid', 'firstName', 'lastName', 'email', 'createdAt'],
|
||||
relations: ['roleType', 'userSpaces'],
|
||||
relations: ['roleType', 'userSpaces.space'],
|
||||
});
|
||||
}
|
||||
if (!user) {
|
||||
@ -149,7 +149,10 @@ export class ProjectUserService {
|
||||
private formatUserResponse(user: any) {
|
||||
const createdAt = new Date(user.createdAt);
|
||||
return {
|
||||
...user,
|
||||
uuid: user.uuid,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
email: user.email,
|
||||
createdDate: createdAt.toLocaleDateString(),
|
||||
createdTime: createdAt.toLocaleTimeString(),
|
||||
...this.normalizeUserProperties(user),
|
||||
@ -163,7 +166,9 @@ export class ProjectUserService {
|
||||
phoneNumber: user.phoneNumber ?? null,
|
||||
jobTitle: user.jobTitle ?? null,
|
||||
roleType: user.roleType?.type ?? null,
|
||||
spaces: user.spaces ?? user.userSpaces,
|
||||
spaces:
|
||||
user?.spaces?.map((space: any) => space?.space) ??
|
||||
user?.userSpaces?.map((space: any) => space?.space),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user