CASH-1315: move all today getters into helper

This commit is contained in:
AdamCaouetteSafelite 2025-12-31 17:04:33 -05:00
parent b2478f4e9e
commit 9c4d2daa3e
3 changed files with 16 additions and 6 deletions

View file

@ -150,6 +150,7 @@ import {
import { import {
convertDateToDateString, convertDateToDateString,
convertDateStringToDate, convertDateStringToDate,
getTodayDateString,
} from "@/layouts/schedule/helpers/schedule-helper"; } from "@/layouts/schedule/helpers/schedule-helper";
import { useField, ErrorMessage } from "vee-validate"; import { useField, ErrorMessage } from "vee-validate";
import { deepClone } from "@/helpers/object-helper"; import { deepClone } from "@/helpers/object-helper";
@ -227,7 +228,7 @@ export default {
}, },
computed: { computed: {
todayString() { todayString() {
return this.todayOverrideDateString || convertDateToDateString(new Date()); return this.todayOverrideDateString || getTodayDateString();
}, },
todayDayIndex() { todayDayIndex() {
return convertDateStringToDate(this.todayString).getDay(); return convertDateStringToDate(this.todayString).getDay();
@ -414,7 +415,7 @@ export default {
} else if (config.todayOverrideDateString) { } else if (config.todayOverrideDateString) {
todayDateString = config.todayOverrideDateString; todayDateString = config.todayOverrideDateString;
} else { } else {
todayDateString = convertDateToDateString(new Date()); todayDateString = getTodayDateString();
} }
if (config.selectableDatesSetting === "past") calendarViewDirection = "past"; if (config.selectableDatesSetting === "past") calendarViewDirection = "past";
if (config.selectableDatesSetting === "custom") calendarViewDirection = "future"; if (config.selectableDatesSetting === "custom") calendarViewDirection = "future";

View file

@ -71,3 +71,11 @@ export function isDropOffRouteCode(routeCode) {
routeCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF) routeCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)
); );
} }
export function getTodayDate(routeCode) {
return new Date();
}
export function getTodayDateString(routeCode) {
return convertDateToDateString(getTodayDate());
}

View file

@ -233,6 +233,7 @@ import {
convertDateStringToDate, convertDateStringToDate,
sumDateString, sumDateString,
isDropOffRouteCode, isDropOffRouteCode,
getTodayDate,
} from "@/layouts/schedule/helpers/schedule-helper"; } from "@/layouts/schedule/helpers/schedule-helper";
import { DAYS_OF_WEEK } from "@/digital-components/date-picker/mixins/constants"; import { DAYS_OF_WEEK } from "@/digital-components/date-picker/mixins/constants";
@ -826,7 +827,7 @@ export default {
} }
}, },
isSameDay() { isSameDay() {
const todaysDate = new Date().toISOString().split("T")[0]; const todaysDate = getTodayDate().toISOString().split("T")[0];
return this.selectedDate === todaysDate; return this.selectedDate === todaysDate;
}, },
isOvernightDropoff() { isOvernightDropoff() {
@ -1100,7 +1101,7 @@ export default {
}, },
getTimeSlotInfo() { getTimeSlotInfo() {
// Get the current date // Get the current date
const currentDate = new Date(); const currentDate = getTodayDate();
// Add 10 days to the current date // Add 10 days to the current date
currentDate.setDate(currentDate.getDate() + 10); currentDate.setDate(currentDate.getDate() + 10);
@ -1403,7 +1404,7 @@ export default {
const type = store.getters.isMobileAppointment ? "mobile" : "inshop"; const type = store.getters.isMobileAppointment ? "mobile" : "inshop";
gaLabel = `${status}_${type}`; gaLabel = `${status}_${type}`;
const currentDate = new Date(); const currentDate = getTodayDate();
const dateString = this.isMobileSelected const dateString = this.isMobileSelected
? this.selectableDatesMobile.days[0].date ? this.selectableDatesMobile.days[0].date
: this.selectableDatesInshop.days[0].date; : this.selectableDatesInshop.days[0].date;
@ -1477,7 +1478,7 @@ export default {
) { ) {
const [year, month, day] = dateString.split("-").map(Number); const [year, month, day] = dateString.split("-").map(Number);
const targetDate = new Date(year, month - 1, day); const targetDate = new Date(year, month - 1, day);
const currentDate = new Date(); const currentDate = getTodayDate();
const futureDate = new Date(currentDate); const futureDate = new Date(currentDate);
const experimentThresholdDays = experimentMixin.methods.hasSetting( const experimentThresholdDays = experimentMixin.methods.hasSetting(
experimentSettings.WAITLIST_THRESHOLD_DAYS experimentSettings.WAITLIST_THRESHOLD_DAYS