Wire in in-shop timeslots call and map the dates

This commit is contained in:
scottkiener-at-safelite 2026-05-04 15:12:22 -04:00
parent bc14f0b3ae
commit cd94b853ee

View file

@ -50,10 +50,6 @@ import {
} from "@/helpers/page-prerequisites-helper.js"; } from "@/helpers/page-prerequisites-helper.js";
import { debugLog } from "@/helpers/debug-log-helper"; import { debugLog } from "@/helpers/debug-log-helper";
// Mock scheduling helpers replace with real API data when integrating
// Offsets of available days within any 15-day block (gaps on days 2, 6, 7, 10, 13)
const MOCK_AVAILABLE_OFFSETS = [0, 1, 3, 4, 5, 8, 9, 11, 12, 14];
function toDateString(offsetDays, base = new Date()) { function toDateString(offsetDays, base = new Date()) {
const d = new Date(base); const d = new Date(base);
d.setDate(d.getDate() + offsetDays); d.setDate(d.getDate() + offsetDays);
@ -68,24 +64,40 @@ export default {
resultKey: "cmsContent", resultKey: "cmsContent",
promise: fetchCmsContentForPage(to.name), promise: fetchCmsContentForPage(to.name),
}, },
{
resultKey: "InshopOrDropoffTimeSlots",
promise: store.dispatch("getShopTimeSlots", {
payload: {
startDate: toDateString(0),
endDate: toDateString(15),
shopAppointmentType: "InshopOrDropoff",
providerNumber: "003417",
},
pageNameToLog: to.name,
}),
},
]; ];
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.InshopOrDropoffTimeSlots = resultMap.InshopOrDropoffTimeSlots;
}); });
}, },
computed: { computed: {
serviceLocationText() { serviceLocationText() {
return this.getCmsContent("ServiceLocationText", "Text"); return this.getCmsContent("ServiceLocationText", "Text");
}, },
availableDates() {
return (this.InshopOrDropoffTimeSlots?.days ?? []).map((d) => d.date);
},
}, },
data() { data() {
return { return {
selectedDate: null, selectedDate: null,
isLoadingDates: false, isLoadingDates: false,
datePickerStartDate: toDateString(0), datePickerStartDate: toDateString(0),
datePickerEndDate: toDateString(14), datePickerEndDate: toDateString(15),
availableDates: MOCK_AVAILABLE_OFFSETS.map((n) => toDateString(n)), InshopOrDropoffTimeSlots: null,
}; };
}, },
methods: { methods: {
@ -139,14 +151,8 @@ export default {
this.isLoadingDates = true; this.isLoadingDates = true;
this.$refs.loadingModal.showModal(); this.$refs.loadingModal.showModal();
await new Promise((resolve) => setTimeout(resolve, 1000)); // TODO: call getShopTimeSlots with the next date range and append results
// to this.availableDates and advance this.datePickerEndDate
const currentEnd = new Date(
...this.datePickerEndDate.split("-").map((n, i) => (i === 1 ? Number(n) - 1 : Number(n)))
);
const newAvailable = MOCK_AVAILABLE_OFFSETS.map((n) => toDateString(n + 1, currentEnd));
this.availableDates = [...this.availableDates, ...newAvailable];
this.datePickerEndDate = toDateString(15, currentEnd);
this.isLoadingDates = false; this.isLoadingDates = false;
this.$refs.loadingModal.hideModal(); this.$refs.loadingModal.hideModal();