Skip to content

Commit

Permalink
fix(field validation): added conditional check for member roles
Browse files Browse the repository at this point in the history
  • Loading branch information
navneethkrish committed Dec 4, 2024
1 parent c8e1210 commit a04e96d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apps/web-api/src/members/members.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1163,7 +1165,7 @@ export class MembersService {
*/
async updatePreference(id: string, preferences: any): Promise<Member> {
const updatedMember = await this.updateMemberByUid(id, { preferences });
await this.cacheService.reset({ service: 'members'});
await this.cacheService.reset({ service: 'members' });
return updatedMember;
}

Expand All @@ -1172,7 +1174,7 @@ export class MembersService {
* This ensures that the system is up-to-date with the latest changes.
*/
private async postUpdateActions(): Promise<void> {
await this.cacheService.reset({ service: 'members'});
await this.cacheService.reset({ service: 'members' });
await this.forestadminService.triggerAirtableSync();
}

Expand Down

0 comments on commit a04e96d

Please sign in to comment.