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

Feat: add voyage project submission status to /me endpoint #158

Merged
merged 7 commits into from
May 29, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Another example [here](https://co-pilot.dev/changelog)
- Add CASL ability for Access control ([#141](https://github.com/chingu-x/chingu-dashboard-be/pull/141))
- Add sprint checkin form submission status for a user ([#149](https://github.com/chingu-x/chingu-dashboard-be/pull/149))
- new command to run both e2e and unit test ([#148](https://github.com/chingu-x/chingu-dashboard-be/pull/148))
- Add voyage project submission status to `/me` endpoint ([#158](https://github.com/chingu-x/chingu-dashboard-be/pull/158))

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/global/selects/users.select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const privateUserDetailSelect = {
},
},
},
FormResponseVoyageProject: true,
},
},
voyageRole: {
Expand Down
28 changes: 25 additions & 3 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class UsersService {
},
select: privateUserDetailSelect,
});

if (!user) throw new NotFoundException("User not found");
// get voyageTeamMemberIds
const teamMemberId: number[] = (
await this.prisma.user.findUnique({
Expand Down Expand Up @@ -107,10 +109,30 @@ export class UsersService {
).map((sprintCheckInId) => sprintCheckInId.sprintId);

// update user object with sprintCheckInIds
const updatedUser = {
...user,
sprintCheckIn: sprintCheckInIds,
voyageTeamMembers: user.voyageTeamMembers.map((teamMember) => {
if (teamMember.voyageTeam.FormResponseVoyageProject) {
return {
...teamMember,
voyageTeam: {
...teamMember.voyageTeam,
projectSubmitted: true,
},
};
} else {
return {
...teamMember,
voyageTeam: {
...teamMember.voyageTeam,
projectSubmitted: false,
},
};
}
}),
};

const updatedUser = { ...user, sprintCheckIn: sprintCheckInIds };

if (!user) throw new NotFoundException("User not found");
return this.formatUser(updatedUser);
}

Expand Down
Loading