Wire in in-shop timeslots call and map the dates
This commit is contained in:
parent
bc14f0b3ae
commit
cd94b853ee
1 changed files with 20 additions and 14 deletions
|
|
@ -50,10 +50,6 @@ import {
|
|||
} from "@/helpers/page-prerequisites-helper.js";
|
||||
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()) {
|
||||
const d = new Date(base);
|
||||
d.setDate(d.getDate() + offsetDays);
|
||||
|
|
@ -68,24 +64,40 @@ export default {
|
|||
resultKey: "cmsContent",
|
||||
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);
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.InshopOrDropoffTimeSlots = resultMap.InshopOrDropoffTimeSlots;
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
serviceLocationText() {
|
||||
return this.getCmsContent("ServiceLocationText", "Text");
|
||||
},
|
||||
availableDates() {
|
||||
return (this.InshopOrDropoffTimeSlots?.days ?? []).map((d) => d.date);
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedDate: null,
|
||||
isLoadingDates: false,
|
||||
datePickerStartDate: toDateString(0),
|
||||
datePickerEndDate: toDateString(14),
|
||||
availableDates: MOCK_AVAILABLE_OFFSETS.map((n) => toDateString(n)),
|
||||
datePickerEndDate: toDateString(15),
|
||||
InshopOrDropoffTimeSlots: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -139,14 +151,8 @@ export default {
|
|||
this.isLoadingDates = true;
|
||||
this.$refs.loadingModal.showModal();
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
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);
|
||||
// TODO: call getShopTimeSlots with the next date range and append results
|
||||
// to this.availableDates and advance this.datePickerEndDate
|
||||
|
||||
this.isLoadingDates = false;
|
||||
this.$refs.loadingModal.hideModal();
|
||||
|
|
|
|||
Loading…
Reference in a new issue