From 9c61f641d86677a60292e7fdcee6ef19c8ab9ac8 Mon Sep 17 00:00:00 2001 From: Dominik Chrastek Date: Fri, 22 Nov 2024 16:28:22 +0100 Subject: [PATCH 1/3] fix: availability helper --- src/models/AvailabilityHelper.ts | 8 +++++++- src/models/__tests__/DateHelper.test.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/models/AvailabilityHelper.ts b/src/models/AvailabilityHelper.ts index d927787..c8ecb9d 100644 --- a/src/models/AvailabilityHelper.ts +++ b/src/models/AvailabilityHelper.ts @@ -1,9 +1,15 @@ import { Availability } from '@octocloud/types'; import { NoAvailabilityError } from './Error'; +import { DateHelper } from './DateHelper'; export class AvailabilityHelper { public static checkAvailability = (availabilities: Availability[], dateString: string): Availability => { - const availability = availabilities.find((availability) => availability.localDateTimeStart === dateString) ?? null; + const availability = availabilities.find((availability) => { + if (availability.allDay) { + return DateHelper.getDate(availability.localDateTimeStart) === DateHelper.getDate(dateString) + } + return availability.localDateTimeStart === dateString + }) ?? null; if (availability === null) { throw new NoAvailabilityError(); } diff --git a/src/models/__tests__/DateHelper.test.ts b/src/models/__tests__/DateHelper.test.ts index e230145..7f6f211 100644 --- a/src/models/__tests__/DateHelper.test.ts +++ b/src/models/__tests__/DateHelper.test.ts @@ -1,5 +1,5 @@ -import { DateHelper } from '../DateHelper'; import { describe, expect, it } from 'vitest'; +import { DateHelper } from '../DateHelper'; describe('DateHelper', () => { const date = '2023-12-01'; From 9b03fc8c8d9c683c125836a573fdd4a23ad6bc8c Mon Sep 17 00:00:00 2001 From: Dominik Chrastek Date: Fri, 22 Nov 2024 16:28:30 +0100 Subject: [PATCH 2/3] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f52b028..fdb3d7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octocloud/core", - "version": "1.0.62", + "version": "1.0.63", "license": "ISC", "author": "", "exports": { From 3f3d2df4b20d6952e35697f25b21c8e6fad076d9 Mon Sep 17 00:00:00 2001 From: Dominik Chrastek Date: Fri, 22 Nov 2024 16:33:18 +0100 Subject: [PATCH 3/3] format --- src/models/AvailabilityHelper.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/models/AvailabilityHelper.ts b/src/models/AvailabilityHelper.ts index c8ecb9d..c46fa9c 100644 --- a/src/models/AvailabilityHelper.ts +++ b/src/models/AvailabilityHelper.ts @@ -4,12 +4,13 @@ import { DateHelper } from './DateHelper'; export class AvailabilityHelper { public static checkAvailability = (availabilities: Availability[], dateString: string): Availability => { - const availability = availabilities.find((availability) => { - if (availability.allDay) { - return DateHelper.getDate(availability.localDateTimeStart) === DateHelper.getDate(dateString) - } - return availability.localDateTimeStart === dateString - }) ?? null; + const availability = + availabilities.find((availability) => { + if (availability.allDay) { + return DateHelper.getDate(availability.localDateTimeStart) === DateHelper.getDate(dateString); + } + return availability.localDateTimeStart === dateString; + }) ?? null; if (availability === null) { throw new NoAvailabilityError(); }