Skip to content

Commit

Permalink
Merge pull request #55 from VentionCapstone/fix/search-refactor-isVal…
Browse files Browse the repository at this point in the history
…idDateRange

Fix/search_refactor
  • Loading branch information
fasbrothers committed Jan 20, 2024
2 parents 470fb9a + d8f65e2 commit e66280e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/accommodation/accommodation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ export class AccommodationService {
};
}

if (this.isInvalidDateRange(checkInDate, checkOutDate)) {
if (!checkInDate && !checkOutDate) return;

if (!checkInDate || !checkOutDate || this.isInvalidDateRange(checkInDate, checkOutDate)) {
throw new BadRequestException(ErrorsTypes.BAD_REQUEST_INVALID_DATE_RANGE);
}

Expand All @@ -411,7 +413,6 @@ export class AccommodationService {
}

private isInvalidDateRange(checkIn: Date | undefined, checkOut: Date | undefined) {
if (!checkIn || !checkOut) return true;
return (
dayjs(checkOut).isSameOrBefore(dayjs(checkIn), 'day') ||
dayjs(checkIn).isBefore(dayjs(), 'day') ||
Expand Down

0 comments on commit e66280e

Please sign in to comment.