From ad1990d8b4fc68d85f57b7f00e6fcb28eb239c14 Mon Sep 17 00:00:00 2001 From: AdamCaouetteSafelite Date: Wed, 31 Dec 2025 17:04:33 -0500 Subject: [PATCH] CASH-1315: move all today getters into helper --- src/digital-components/date-picker/date-picker.vue | 5 +++-- src/layouts/schedule/helpers/schedule-helper.js | 8 ++++++++ src/layouts/schedule/schedule.vue | 9 +++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/digital-components/date-picker/date-picker.vue b/src/digital-components/date-picker/date-picker.vue index 6f635d0bc..d586ff839 100644 --- a/src/digital-components/date-picker/date-picker.vue +++ b/src/digital-components/date-picker/date-picker.vue @@ -150,6 +150,7 @@ import { import { convertDateToDateString, convertDateStringToDate, + getTodayDateString, } from "@/layouts/schedule/helpers/schedule-helper"; import { useField, ErrorMessage } from "vee-validate"; import { deepClone } from "@/helpers/object-helper"; @@ -227,7 +228,7 @@ export default { }, computed: { todayString() { - return this.todayOverrideDateString || convertDateToDateString(new Date()); + return this.todayOverrideDateString || getTodayDateString(); }, todayDayIndex() { return convertDateStringToDate(this.todayString).getDay(); @@ -425,7 +426,7 @@ export default { } else if (config.todayOverrideDateString) { todayDateString = config.todayOverrideDateString; } else { - todayDateString = convertDateToDateString(new Date()); + todayDateString = getTodayDateString(); } if (config.selectableDatesSetting === "past") calendarViewDirection = "past"; if (config.selectableDatesSetting === "custom") calendarViewDirection = "future"; diff --git a/src/layouts/schedule/helpers/schedule-helper.js b/src/layouts/schedule/helpers/schedule-helper.js index 41a1cd66a..85df8aa43 100644 --- a/src/layouts/schedule/helpers/schedule-helper.js +++ b/src/layouts/schedule/helpers/schedule-helper.js @@ -71,3 +71,11 @@ export function isDropOffRouteCode(routeCode) { routeCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF) ); } + +export function getTodayDate(routeCode) { + return new Date(); +} + +export function getTodayDateString(routeCode) { + return convertDateToDateString(getTodayDate()); +} diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index af7e67bd0..01b9841c0 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -233,6 +233,7 @@ import { convertDateStringToDate, sumDateString, isDropOffRouteCode, + getTodayDate, } from "@/layouts/schedule/helpers/schedule-helper"; import { DAYS_OF_WEEK } from "@/digital-components/date-picker/mixins/constants"; @@ -826,7 +827,7 @@ export default { } }, isSameDay() { - const todaysDate = new Date().toISOString().split("T")[0]; + const todaysDate = getTodayDate().toISOString().split("T")[0]; return this.selectedDate === todaysDate; }, isOvernightDropoff() { @@ -1100,7 +1101,7 @@ export default { }, getTimeSlotInfo() { // Get the current date - const currentDate = new Date(); + const currentDate = getTodayDate(); // Add 10 days to the current date currentDate.setDate(currentDate.getDate() + 10); @@ -1403,7 +1404,7 @@ export default { const type = store.getters.isMobileAppointment ? "mobile" : "inshop"; gaLabel = `${status}_${type}`; - const currentDate = new Date(); + const currentDate = getTodayDate(); const dateString = this.isMobileSelected ? this.selectableDatesMobile.days[0].date : this.selectableDatesInshop.days[0].date; @@ -1477,7 +1478,7 @@ export default { ) { const [year, month, day] = dateString.split("-").map(Number); const targetDate = new Date(year, month - 1, day); - const currentDate = new Date(); + const currentDate = getTodayDate(); const futureDate = new Date(currentDate); const experimentThresholdDays = experimentMixin.methods.hasSetting( experimentSettings.WAITLIST_THRESHOLD_DAYS