Skip to content

Commit

Permalink
fix: team page member sort (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpvsalvador authored Jan 12, 2023
1 parent 47a5383 commit 2d9ad01
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions backend/src/modules/teams/services/get.team.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@ export default class GetTeamService implements GetTeamServiceInterface {
return this.teamRepository.countDocuments();
}

getTeam(teamId: string) {
return this.teamRepository.getTeam(teamId);
async getTeam(teamId: string) {
const team = await this.teamRepository.getTeam(teamId);

team.users.sort((a, b) => {
const userA = a.user as User;
const userB = b.user as User;

const fullNameA = `${userA.firstName.toLowerCase()} ${userA.lastName.toLowerCase()}`;
const fullNameB = `${userB.firstName.toLowerCase()} ${userB.lastName.toLowerCase()}`;

return fullNameA < fullNameB ? -1 : 1;
});

return team;
}

async getTeamsOfUser(userId: string) {
Expand Down

0 comments on commit 2d9ad01

Please sign in to comment.