From 6694c354da28e95bb9e6e6ee5433171d80e6379d Mon Sep 17 00:00:00 2001 From: Clerise Swart Date: Wed, 30 Oct 2024 16:44:58 +0200 Subject: [PATCH] feat: align pickup times with API data Fixed weekday ordering and mapped pickup times accurately to match API data. Closes #INT-663 --- .../src/utils/createNextDate.ts | 8 +- .../PickupLocationOpeningHours.vue | 110 +++++++++++------- libs/shared/src/utils/createTimestamp.ts | 6 +- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/apps/delivery-options/src/utils/createNextDate.ts b/apps/delivery-options/src/utils/createNextDate.ts index da205326..3271324f 100644 --- a/apps/delivery-options/src/utils/createNextDate.ts +++ b/apps/delivery-options/src/utils/createNextDate.ts @@ -7,10 +7,12 @@ import {createUtcDate} from './createUtcDate'; */ export const createNextDate = (weekday: number): Date => { const date = createUtcDate(); + const currentDay = getDay(date); + let days = weekday - currentDay; - if (getDay(date) === weekday) { - return date; + if (days < 0) { + days += DAYS_IN_WEEK; } - return addDays(date, (weekday + DAYS_IN_WEEK - getDay(date)) % DAYS_IN_WEEK); + return addDays(date, days); }; diff --git a/apps/delivery-options/src/views/MyParcelDeliveryOptions/Pickup/PickupLocationOpeningHours/PickupLocationOpeningHours.vue b/apps/delivery-options/src/views/MyParcelDeliveryOptions/Pickup/PickupLocationOpeningHours/PickupLocationOpeningHours.vue index a55c37d4..aa6fca9f 100644 --- a/apps/delivery-options/src/views/MyParcelDeliveryOptions/Pickup/PickupLocationOpeningHours/PickupLocationOpeningHours.vue +++ b/apps/delivery-options/src/views/MyParcelDeliveryOptions/Pickup/PickupLocationOpeningHours/PickupLocationOpeningHours.vue @@ -1,66 +1,94 @@