diff --git a/apps/web-api/src/members/members.service.ts b/apps/web-api/src/members/members.service.ts index 9ca07790c..2aaeab285 100644 --- a/apps/web-api/src/members/members.service.ts +++ b/apps/web-api/src/members/members.service.ts @@ -41,7 +41,7 @@ export class MembersService { @Inject(forwardRef(() => NotificationService)) private notificationService: NotificationService, private cacheService: CacheService - ) {} + ) { } /** * Creates a new member in the database within a transaction. @@ -426,7 +426,7 @@ export class MembersService { newTokens = await this.authService.updateEmailInAuth(newEmail, oldEmail, memberInfo.externalId) }); this.logger.info(`Email has been successfully updated from ${oldEmail} to ${newEmail}`) - await this.cacheService.reset({ service: 'members'}); + await this.cacheService.reset({ service: 'members' }); return { refreshToken: newTokens.refresh_token, idToken: newTokens.id_token, @@ -717,7 +717,9 @@ export class MembersService { : type === 'Update' ? { disconnect: true } : undefined; member['skills'] = buildMultiRelationMapping('skills', memberData, type); if (type === 'Create') { - member['teamMemberRoles'] = this.buildTeamMemberRoles(memberData); + if (Array.isArray(memberData.teamMemberRoles)) { + member['teamMemberRoles'] = this.buildTeamMemberRoles(memberData); + } if (Array.isArray(memberData.projectContributions)) { member['projectContributions'] = { createMany: { data: memberData.projectContributions }, @@ -917,7 +919,7 @@ export class MembersService { private buildTeamMemberRoles(memberData) { return { createMany: { - data: memberData.teamAndRoles.map((t) => ({ + data: memberData.teamAndRoles?.map((t) => ({ role: t.role, mainTeam: false, teamLead: false, @@ -1163,7 +1165,7 @@ export class MembersService { */ async updatePreference(id: string, preferences: any): Promise { const updatedMember = await this.updateMemberByUid(id, { preferences }); - await this.cacheService.reset({ service: 'members'}); + await this.cacheService.reset({ service: 'members' }); return updatedMember; } @@ -1172,7 +1174,7 @@ export class MembersService { * This ensures that the system is up-to-date with the latest changes. */ private async postUpdateActions(): Promise { - await this.cacheService.reset({ service: 'members'}); + await this.cacheService.reset({ service: 'members' }); await this.forestadminService.triggerAirtableSync(); }