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: verifyNewJoiner function in backend #843

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions backend/src/modules/boards/services/create.board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class CreateBoardServiceImpl implements CreateBoardService {

const maxDateToBeNewJoiner = addMonths(dateToCompare, 3);

return !isAfter(maxDateToBeNewJoiner, new Date());
return isAfter(maxDateToBeNewJoiner, new Date());
};

async splitBoardByTeam(
Expand All @@ -209,7 +209,7 @@ export default class CreateBoardServiceImpl implements CreateBoardService {

if (
teamUser.isNewJoiner &&
this.verifyIfIsNewJoiner(user.joinedAt, user.providerAccountCreatedAt)
!this.verifyIfIsNewJoiner(user.joinedAt, user.providerAccountCreatedAt)
) {
this.updateTeamService.updateTeamUser({
team: teamId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class TeamUserRepository
getUsersOfTeam(teamId: string) {
return this.findAllWithQuery({ team: teamId }, 'user role isNewJoiner _id', {
path: 'user',
select: '_id firstName lastName email isSAdmin providerAccountCreatedAt'
select: '_id firstName lastName email isSAdmin joinedAt providerAccountCreatedAt'
});
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/verifyIfIsNewJoiner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addMonths, isAfter, parseISO } from 'date-fns';
export const verifyIfIsNewJoiner = (joinedAt: string, providerAccountCreatedAt?: string) => {
const dateToCompare = parseISO(providerAccountCreatedAt || joinedAt);

const maxDateToBeNewJoiner = addMonths(dateToCompare, 2);
const maxDateToBeNewJoiner = addMonths(dateToCompare, 3);

return isAfter(maxDateToBeNewJoiner, new Date());
};