Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: team page member sort #852

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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