CASH-1315: move all today getters into helper

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

View file

@ -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";

View file

@ -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());
}

View file

@ -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