From 4f705aa44b6f67fe8d11e5725cd6b5346e8bb1ac Mon Sep 17 00:00:00 2001 From: Birloi Florian Date: Tue, 20 Aug 2024 15:26:58 +0300 Subject: [PATCH] fix: 223 - allow the user to join organization by access code until the end of the end date validity of the access code --- .../volunteer/join-organization-by-access-code.usecase.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/usecases/volunteer/join-organization-by-access-code.usecase.ts b/backend/src/usecases/volunteer/join-organization-by-access-code.usecase.ts index c476b3a05..ba0126d34 100644 --- a/backend/src/usecases/volunteer/join-organization-by-access-code.usecase.ts +++ b/backend/src/usecases/volunteer/join-organization-by-access-code.usecase.ts @@ -9,7 +9,7 @@ import { } from 'src/modules/volunteer/model/volunteer.model'; import { CreateVolunteerUseCase } from './create-volunteer.usecase'; import { AccessCodeFacade } from 'src/modules/organization/services/access-code.facade'; -import { compareAsc } from 'date-fns'; +import { compareAsc, endOfDay, startOfDay } from 'date-fns'; import { AccessCodeExceptionMessages } from 'src/modules/organization/exceptions/access-codes.exceptions'; @Injectable() @@ -52,8 +52,9 @@ export class JoinOrganizationByAccessCodeUsecase // check fi the access code is valid if ( - compareAsc(accessCode.startDate, new Date()) > 0 || - (accessCode.endDate && compareAsc(accessCode.endDate, new Date()) < 0) + compareAsc(startOfDay(accessCode.startDate), new Date()) > 0 || + (accessCode.endDate && + compareAsc(endOfDay(accessCode.endDate), new Date()) < 0) ) { this.exceptionService.badRequestException( AccessCodeExceptionMessages.ACCESS_CODE_001,