CSR-1131: preliminary work on getting API call from schedule page to date picker
This commit is contained in:
parent
9179506df8
commit
a355b025c1
5 changed files with 319 additions and 97 deletions
|
|
@ -94,6 +94,11 @@ const endpoints = {
|
||||||
url: "/parts/api/v1/parts/part-from-capability-answer",
|
url: "/parts/api/v1/parts/part-from-capability-answer",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
|
GetShopTimeSlots: {
|
||||||
|
url: "/schedule/api/v1/schedule/shop-time-slots",
|
||||||
|
mockUrl: "https://mockey.qa.sagaws.net/service/shop-time-slots", // TODO: REMOVE MOCKURL
|
||||||
|
method: "POST",
|
||||||
|
},
|
||||||
SaveSession: {
|
SaveSession: {
|
||||||
url: "/order/api/v1/order/save-session",
|
url: "/order/api/v1/order/save-session",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ const storeActions = {
|
||||||
GET_MOLDING_QUESTIONS: "getMoldingQuestions",
|
GET_MOLDING_QUESTIONS: "getMoldingQuestions",
|
||||||
GET_MOBILE_FEE_PART: "getMobileFeePart",
|
GET_MOBILE_FEE_PART: "getMobileFeePart",
|
||||||
GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails",
|
GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails",
|
||||||
|
GET_SHOP_TIME_SLOTS: "getShopTimeSlots",
|
||||||
SAVE_SESSION: "saveSession",
|
SAVE_SESSION: "saveSession",
|
||||||
LOAD_SESSION: "loadSession",
|
LOAD_SESSION: "loadSession",
|
||||||
UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE: "updateStoreWithSaveSessionResponse",
|
UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE: "updateStoreWithSaveSessionResponse",
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,58 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="date-picker text-center" :class="calendarViewDirection">
|
<div class="date-picker text-center" :class="calendarViewDirection">
|
||||||
<fieldset v-if="months">
|
<!-- <p style="text-align: left">savedHeight: {{ savedHeight }}</p> -->
|
||||||
|
<!-- <p style="text-align: left">selectableDatesData: {{ selectableDatesData }}</p> -->
|
||||||
|
<!-- <p style="text-align: left">months: {{ months }}</p> -->
|
||||||
|
<fieldset v-if="months" id="date-picker-fieldset">
|
||||||
<legend class="sr-only">Date Picker</legend>
|
<legend class="sr-only">Date Picker</legend>
|
||||||
|
<h4 id="tracker">currentScrollTop: {{ currentScrollTop }}</h4>
|
||||||
<div
|
<div
|
||||||
v-for="month in months"
|
v-for="month in months"
|
||||||
:key="`${month.monthLabel}-${month.yearNum.toString()}-${months.length}`">
|
:key="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
||||||
|
:id="`${month.monthLabel}-${month.yearNum?.toString()}`"
|
||||||
|
class="calendar-grid-container position-relative"
|
||||||
|
:class="[
|
||||||
|
isInitialView === true ? 'initial-view' : '',
|
||||||
|
month.monthClass,
|
||||||
|
isAddingNewMonth === true ? 'is-adding-new-month' : '',
|
||||||
|
]">
|
||||||
|
<div class="month-year body-small d-flex align-items-center small">
|
||||||
|
{{ month.monthLabel }} {{ month.yearNum?.toString() }}
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="calendar-grid-container position-relative"
|
v-if="calendarViewDirection === 'future'"
|
||||||
|
class="legend caption d-flex align-items-center justify-content-end">
|
||||||
|
<span class="legend-circle me-1"></span> = Available
|
||||||
|
</div>
|
||||||
|
<div class="separator-line"></div>
|
||||||
|
<div class="nav-back ps-3"><button></button></div>
|
||||||
|
<div class="nav-forward pe-3"><button></button></div>
|
||||||
|
<!-- Do the days of the weeek need to be read? -->
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Sunday</span>S</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Monday</span>M</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Tuesday</span>T</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Wednesday</span>W</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Thursday</span>T</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Friday</span>F</div>
|
||||||
|
<div class="grid-item caption"><span class="sr-only">Saturday</span>S</div>
|
||||||
|
<div
|
||||||
|
v-for="date in month.dates"
|
||||||
|
:key="`${month.monthLabel}-${date.dateNum.toString()}-${months.length}`"
|
||||||
|
class="grid-item radio-wrapper"
|
||||||
:class="[
|
:class="[
|
||||||
isInitialView === true ? 'initial-view' : '',
|
date.dateNum === 1 ? 'first-day-' + month.startDateDayIndex : '',
|
||||||
month.monthClass,
|
date.dayClasses,
|
||||||
isAddingNewMonth === true ? 'is-adding-new-month' : '',
|
|
||||||
]">
|
]">
|
||||||
<div class="month-year body-small d-flex align-items-center small">
|
<input
|
||||||
{{ month.monthLabel }} {{ month.yearNum.toString() }}
|
:disabled="!isSelectableDate(date.inputValue)"
|
||||||
</div>
|
type="radio"
|
||||||
<div
|
name="day-of-month"
|
||||||
v-if="calendarViewDirection === 'future'"
|
v-model="selectedDate"
|
||||||
class="legend caption d-flex align-items-center justify-content-end">
|
:value="date.inputValue"
|
||||||
<span class="legend-circle me-1"></span> = Available
|
:id="`${month.monthLabel}-${date.dateNum.toString()}`" />
|
||||||
</div>
|
<label :for="`${month.monthLabel}-${date.dateNum.toString()}`">
|
||||||
<div class="separator-line"></div>
|
<span>{{ date.dateNum.toString() }}</span>
|
||||||
<div class="nav-back ps-3"><button></button></div>
|
</label>
|
||||||
<div class="nav-forward pe-3"><button></button></div>
|
|
||||||
<!-- Do the days of the weeek need to be read? -->
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Sunday</span>S</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Monday</span>M</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Tuesday</span>T</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Wednesday</span>W</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Thursday</span>T</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Friday</span>F</div>
|
|
||||||
<div class="grid-item caption"><span class="sr-only">Saturday</span>S</div>
|
|
||||||
<div
|
|
||||||
v-for="date in month.dates"
|
|
||||||
:key="`${month.monthLabel}-${date.dateNum.toString()}-${months.length}`"
|
|
||||||
class="grid-item radio-wrapper"
|
|
||||||
:class="[
|
|
||||||
date.dateNum === 1 ? 'first-day-' + month.startDateDayIndex : '',
|
|
||||||
date.dayClasses,
|
|
||||||
]">
|
|
||||||
<input
|
|
||||||
:disabled="!isSelectableDate(date.inputValue)"
|
|
||||||
type="radio"
|
|
||||||
name="day-of-month"
|
|
||||||
v-model="selectedDate"
|
|
||||||
:value="date.inputValue"
|
|
||||||
:id="`${month.monthLabel}-${date.dateNum.toString()}`" />
|
|
||||||
<label :for="`${month.monthLabel}-${date.dateNum.toString()}`">
|
|
||||||
<span>{{ date.dateNum.toString() }}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
@ -76,7 +79,7 @@ export default {
|
||||||
name: "datePicker",
|
name: "datePicker",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
calendarData: [],
|
// calendarData: [],
|
||||||
monthsBeforeToLoadOffset: 0,
|
monthsBeforeToLoadOffset: 0,
|
||||||
monthsAfterToLoadOffset: 1,
|
monthsAfterToLoadOffset: 1,
|
||||||
selectableDatesData: [], // NOTE: uses monthNum (1-based), NOT monthIndex (0-based)
|
selectableDatesData: [], // NOTE: uses monthNum (1-based), NOT monthIndex (0-based)
|
||||||
|
|
@ -84,10 +87,21 @@ export default {
|
||||||
initialViewRowsToShow: 5,
|
initialViewRowsToShow: 5,
|
||||||
initialViewRowsTally: 0,
|
initialViewRowsTally: 0,
|
||||||
isAddingNewMonth: false,
|
isAddingNewMonth: false,
|
||||||
|
|
||||||
|
savedHeight: 0,
|
||||||
|
newestMonthId: "",
|
||||||
|
currentScrollTop: 0,
|
||||||
|
months: null, // NEW
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.setCalendarData();
|
||||||
|
// this.trackScrollTop();
|
||||||
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
selectableDates: {
|
selectableDatesSetting: {
|
||||||
type: String,
|
type: String,
|
||||||
validator(value) {
|
validator(value) {
|
||||||
return Object.values(SelectableDaysOptions).includes(value);
|
return Object.values(SelectableDaysOptions).includes(value);
|
||||||
|
|
@ -105,6 +119,7 @@ export default {
|
||||||
customSelectableDatesCallback: {
|
customSelectableDatesCallback: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default() {
|
default() {
|
||||||
|
// console.log(" running default...")
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -115,15 +130,16 @@ export default {
|
||||||
? new Date(this.todayOverrideDateString)
|
? new Date(this.todayOverrideDateString)
|
||||||
: new Date();
|
: new Date();
|
||||||
},
|
},
|
||||||
months() {
|
// months() {
|
||||||
if (this.calendarData?.length < 1) {
|
// if (this.calendarData?.length < 1) {
|
||||||
this.setCalendarData();
|
// this.setCalendarData();
|
||||||
}
|
// }
|
||||||
return this.calendarData;
|
// console.log("( ( (( ( ()))))) MONTHS READY")
|
||||||
},
|
// return this.calendarData;
|
||||||
|
// },
|
||||||
calendarViewDirection() {
|
calendarViewDirection() {
|
||||||
if (this.selectableDates === "past") return "past";
|
if (this.selectableDatesSetting === "past") return "past";
|
||||||
if (this.selectableDates === "custom") return "future";
|
if (this.selectableDatesSetting === "custom") return "future";
|
||||||
return "none";
|
return "none";
|
||||||
},
|
},
|
||||||
selectedDate: {
|
selectedDate: {
|
||||||
|
|
@ -136,6 +152,12 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// setMonths() { /// NEW, ONLY RUN ON MOUNTED?
|
||||||
|
// if (this.months?.length < 1) { // DO I NEED THIS CHECK, IF ONLY TRIGGERED WITH MOUNTED HOOK NOW?
|
||||||
|
// this.setCalendarData();
|
||||||
|
// }
|
||||||
|
// // this.months = this.calendarData;
|
||||||
|
// },
|
||||||
goForward() {
|
goForward() {
|
||||||
if (this.isInitialView) {
|
if (this.isInitialView) {
|
||||||
this.isInitialView = false; // 1st click removes hidden styling
|
this.isInitialView = false; // 1st click removes hidden styling
|
||||||
|
|
@ -143,13 +165,16 @@ export default {
|
||||||
this.addMonthData(); // 2nd click adds 1 month data
|
this.addMonthData(); // 2nd click adds 1 month data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCalendarData() {
|
async setCalendarData() {
|
||||||
|
// console.log(" running setCalendarData.")
|
||||||
|
// this.selectableDatesData = this.selectableDates; // POPULATE DATA FROM PROP
|
||||||
|
|
||||||
// GENERATE MONTHS AND PUSH THEM INTO ARRAY
|
// GENERATE MONTHS AND PUSH THEM INTO ARRAY
|
||||||
const months = [];
|
const months = [];
|
||||||
if (this.calendarViewDirection === "future") {
|
if (this.calendarViewDirection === "future") {
|
||||||
// first 0, then 1
|
// first 0, then 1
|
||||||
for (let i = 0; i <= this.monthsAfterToLoadOffset; i++) {
|
for (let i = 0; i <= this.monthsAfterToLoadOffset; i++) {
|
||||||
months.push(this.getMonthData(i));
|
months.push(await this.getMonthData(i));
|
||||||
}
|
}
|
||||||
} else if (this.calendarViewDirection === "past") {
|
} else if (this.calendarViewDirection === "past") {
|
||||||
// first 0, then -1
|
// first 0, then -1
|
||||||
|
|
@ -162,9 +187,11 @@ export default {
|
||||||
// months.push(this.getMonthDataPAST(i));
|
// months.push(this.getMonthDataPAST(i));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
this.calendarData = months;
|
// this.calendarData = months;
|
||||||
|
this.months = months;
|
||||||
|
// console.log(" MONTHS are done ")
|
||||||
},
|
},
|
||||||
getMonthData(offset) {
|
async getMonthData(offset) {
|
||||||
const direction = this.calendarViewDirection; // "past" or "future"
|
const direction = this.calendarViewDirection; // "past" or "future"
|
||||||
let yearNum;
|
let yearNum;
|
||||||
let monthIndex;
|
let monthIndex;
|
||||||
|
|
@ -198,7 +225,7 @@ export default {
|
||||||
|
|
||||||
if (direction === "future") {
|
if (direction === "future") {
|
||||||
// get last day of current calendar data
|
// get last day of current calendar data
|
||||||
const lastMonthInCalendarData = this.calendarData[this.calendarData.length - 1];
|
const lastMonthInCalendarData = this.months[this.months.length - 1];
|
||||||
|
|
||||||
if (lastMonthInCalendarData.monthIndex === 11) {
|
if (lastMonthInCalendarData.monthIndex === 11) {
|
||||||
monthIndex = 0;
|
monthIndex = 0;
|
||||||
|
|
@ -210,7 +237,7 @@ export default {
|
||||||
}
|
}
|
||||||
if (direction === "past") {
|
if (direction === "past") {
|
||||||
// get last day of current calendar data
|
// get last day of current calendar data
|
||||||
const firstMonthInCalendarData = this.calendarData[0];
|
const firstMonthInCalendarData = this.months[0];
|
||||||
|
|
||||||
if (firstMonthInCalendarData.monthIndex === 0) {
|
if (firstMonthInCalendarData.monthIndex === 0) {
|
||||||
monthIndex = 11;
|
monthIndex = 11;
|
||||||
|
|
@ -281,7 +308,7 @@ export default {
|
||||||
monthClass = monthClass + " new-month";
|
monthClass = monthClass + " new-month";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selectableDates === "custom") {
|
if (this.selectableDatesSetting === "custom") {
|
||||||
const monthStart = {
|
const monthStart = {
|
||||||
year: yearNum,
|
year: yearNum,
|
||||||
month: monthIndex + 1,
|
month: monthIndex + 1,
|
||||||
|
|
@ -293,18 +320,27 @@ export default {
|
||||||
date: monthEndDateNum,
|
date: monthEndDateNum,
|
||||||
};
|
};
|
||||||
// get available dates
|
// get available dates
|
||||||
this.updateSelectableDates(monthStart, monthEnd);
|
await this.updateSelectableDates(monthStart, monthEnd); // v v v v v v
|
||||||
|
// MAKE API CALL, ADDS NEW DATES TO this.selectableDatesData
|
||||||
|
}
|
||||||
|
|
||||||
|
function forceTwoDigitString(monthNum) {
|
||||||
|
let newString = monthNum.toString();
|
||||||
|
return (newString.length === 1) ? "0" + newString : newString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate datesArray
|
// populate datesArray
|
||||||
for (let i = monthStartDateNum; i <= monthEndDateNum; i++) {
|
for (let i = monthStartDateNum; i <= monthEndDateNum; i++) {
|
||||||
let dayClasses = "";
|
let dayClasses = "";
|
||||||
|
|
||||||
const thisDate = {
|
const thisDate = {
|
||||||
// NOTE: uses monthNum (1-based), NOT monthIndex (0-based)
|
// NOTE: uses monthNum (1-based), NOT monthIndex (0-based)
|
||||||
year: yearNum,
|
year: yearNum,
|
||||||
month: monthIndex + 1,
|
month: monthIndex + 1,
|
||||||
date: i,
|
date: i,
|
||||||
|
dateString: yearNum.toString() + "-" + forceTwoDigitString(monthIndex + 1) + "-" + forceTwoDigitString(i),
|
||||||
};
|
};
|
||||||
|
let isSelectableDate = this.isSelectableDate(thisDate);
|
||||||
if (offset === 0 && i === todayDateNum) {
|
if (offset === 0 && i === todayDateNum) {
|
||||||
dayClasses += "current-day";
|
dayClasses += "current-day";
|
||||||
}
|
}
|
||||||
|
|
@ -320,9 +356,16 @@ export default {
|
||||||
if (Math.abs(offset) === 1 && direction === "past" && i < initialViewStartDate) {
|
if (Math.abs(offset) === 1 && direction === "past" && i < initialViewStartDate) {
|
||||||
dayClasses += "day-hidden";
|
dayClasses += "day-hidden";
|
||||||
}
|
}
|
||||||
if (this.selectableDates === "custom" && this.isSelectableDate(thisDate)) {
|
if (this.selectableDatesSetting === "custom" && isSelectableDate) {
|
||||||
|
// console.log(" ! ! ! FOUND ONE! A SELECTABLE DATE ! ! ! ! ")
|
||||||
dayClasses += " selectable-day";
|
dayClasses += " selectable-day";
|
||||||
}
|
}
|
||||||
|
// // TEMP CHECK
|
||||||
|
// if (offset === 0 && todayDateNum === 21 || offset === 0 && todayDateNum === 26) {
|
||||||
|
// console.log("dayClasses are: ", dayClasses)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// =====
|
||||||
const dateObject = {
|
const dateObject = {
|
||||||
dateNum: i,
|
dateNum: i,
|
||||||
dayClasses: dayClasses,
|
dayClasses: dayClasses,
|
||||||
|
|
@ -340,49 +383,100 @@ export default {
|
||||||
monthClass: monthClass,
|
monthClass: monthClass,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// debugger; // eslint-disable-line no-debugger
|
||||||
|
|
||||||
|
// console.log(" mmm mm m mm m m m MONTH IS READY mm m m m m m m m mmmm m mm")
|
||||||
|
|
||||||
return monthToAdd;
|
return monthToAdd;
|
||||||
},
|
},
|
||||||
addMonthData() {
|
async addMonthData() {
|
||||||
this.isAddingNewMonth = true;
|
this.isAddingNewMonth = true; // TODO - DO I NEED THIS ANYMIRE?
|
||||||
|
|
||||||
|
const monthToAdd = await this.getMonthData();
|
||||||
|
|
||||||
|
this.newestMonthId = monthToAdd.monthLabel + "-" + monthToAdd.yearNum?.toString();
|
||||||
|
// console.log("newestMonthId: ", this.newestMonthId)
|
||||||
|
|
||||||
const monthToAdd = this.getMonthData();
|
|
||||||
if (this.calendarViewDirection === "future") {
|
if (this.calendarViewDirection === "future") {
|
||||||
let month = this.calendarData[this.calendarData.length - 1];
|
let month = this.months[this.months.length - 1];
|
||||||
month.monthClass = month.monthClass.replace("new-month", "");
|
month.monthClass = month.monthClass.replace("new-month", "");
|
||||||
this.calendarData.push(monthToAdd);
|
this.months.push(monthToAdd);
|
||||||
}
|
}
|
||||||
if (this.calendarViewDirection === "past") {
|
if (this.calendarViewDirection === "past") {
|
||||||
let month = this.calendarData[0];
|
let month = this.months[0];
|
||||||
month.monthClass = month.monthClass.replace("new-month", "");
|
month.monthClass = month.monthClass.replace("new-month", "");
|
||||||
this.calendarData.unshift(monthToAdd);
|
this.months.unshift(monthToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
this.isAddingNewMonth = false;
|
||||||
this.isAddingNewMonth = false;
|
// scroll the next question into view
|
||||||
}, 0.010);
|
|
||||||
|
// == ATTEMPT 3
|
||||||
|
// this.$nextTick(() => {
|
||||||
|
// // setTimeout(() => {
|
||||||
|
// // this.isAddingNewMonth = false;
|
||||||
|
// // }, 0.010);
|
||||||
|
// setTimeout(() => {
|
||||||
|
// document.querySelector("#April-2023-3")?.scrollIntoView({ behavior: "smooth" });
|
||||||
|
// }, 0.01);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // scroll the next question into view
|
||||||
|
// this.$nextTick(() => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// this.isAddingNewMonth = false;
|
||||||
|
// }, 0.010);
|
||||||
|
// setTimeout(() => {
|
||||||
|
// document.querySelector(".new-month")?.scrollIntoView({ behavior: "smooth" });
|
||||||
|
// }, 0.010);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// setTimeout(() => {
|
||||||
|
// this.isAddingNewMonth = false;
|
||||||
|
// }, 0.01);
|
||||||
},
|
},
|
||||||
isSelectableDate(thisDate) {
|
isSelectableDate(thisDate) {
|
||||||
const testForDate = (dateInArray) => {
|
const testForDate = (dateInArray) => {
|
||||||
|
|
||||||
|
// console.log(" running isSelectableDate/testForDate... thisDate.month: ", thisDate.month, " / thisDate.date: ", thisDate.date)
|
||||||
|
// console.log(" running isSelectableDate/testForDate... dateInArray.month: ", dateInArray.month, " / dateInArray.date: ", dateInArray.date)
|
||||||
|
|
||||||
|
// debugger; // eslint-disable-line no-debugger
|
||||||
return (
|
return (
|
||||||
dateInArray.date === thisDate.date &&
|
dateInArray.dateString === thisDate.dateString
|
||||||
dateInArray.month === thisDate.month &&
|
|
||||||
dateInArray.year === thisDate.year
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const isSelectable =
|
// function testForDateNEW(dateInArray) {
|
||||||
this.selectableDatesData.findIndex(testForDate) > -1 ? true : false;
|
|
||||||
|
// console.log(" running isSelectableDate/testForDate... thisDate.month: ", thisDate.month, " / thisDate.date: ", thisDate.date)
|
||||||
|
// console.log(" running isSelectableDate/testForDate... dateInArray.month: ", dateInArray.month, " / dateInArray.date: ", dateInArray.date)
|
||||||
|
|
||||||
|
// // debugger; // eslint-disable-line no-debugger
|
||||||
|
// return (
|
||||||
|
// dateInArray.date === thisDate.date &&
|
||||||
|
// dateInArray.month === thisDate.month &&
|
||||||
|
// dateInArray.year === thisDate.year
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
const midTest = this.selectableDatesData.findIndex(testForDate);
|
||||||
|
// console.log("midTest ", midTest)
|
||||||
|
const isSelectable = (this.selectableDatesData.findIndex(testForDate)) > -1 ? true : false;
|
||||||
|
// debugger; // eslint-disable-line no-debugger
|
||||||
|
// console.log("running isSelectableDate... thisDate: ", thisDate, " / isSelectable: ", isSelectable)
|
||||||
|
|
||||||
return isSelectable;
|
return isSelectable;
|
||||||
},
|
},
|
||||||
updateSelectableDates(monthStart, monthEnd) {
|
async updateSelectableDates(monthStart, monthEnd) {
|
||||||
this.customSelectableDatesCallback(monthStart, monthEnd)?.forEach((newObj) => {
|
// console.log("running DP updateSelectableDates... ")
|
||||||
|
const test = await this.customSelectableDatesCallback(monthStart, monthEnd);
|
||||||
|
|
||||||
|
test?.forEach((newObj) => {
|
||||||
const index = this.selectableDatesData.findIndex(
|
const index = this.selectableDatesData.findIndex(
|
||||||
(obj) =>
|
(obj) => obj.dateString === newObj.dateString
|
||||||
obj.year === newObj.year &&
|
|
||||||
obj.month === newObj.month &&
|
|
||||||
obj.date === newObj.date
|
|
||||||
);
|
);
|
||||||
if (index === -1) this.selectableDatesData.push(newObj);
|
if (index === -1) this.selectableDatesData.push(newObj);
|
||||||
});
|
});
|
||||||
|
// console.log("running DP updateSelectableDates... this.selectableDatesData now: ", this.selectableDatesData)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
||||||
|
<!-- <h3>shopTimeSlots: {{ shopTimeSlots }}</h3> -->
|
||||||
<div class="page-container-grouped-styles">
|
<div class="page-container-grouped-styles">
|
||||||
<loadingModal ref="loadingModal" />
|
<loadingModal ref="loadingModal" />
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||||
|
|
@ -19,7 +20,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<date-picker
|
<date-picker
|
||||||
selectableDates="custom"
|
selectableDatesSetting="custom"
|
||||||
v-model="selectedDate"
|
v-model="selectedDate"
|
||||||
:customSelectableDatesCallback="getAvailableDates" />
|
:customSelectableDatesCallback="getAvailableDates" />
|
||||||
<funnel-footer
|
<funnel-footer
|
||||||
|
|
@ -43,6 +44,8 @@ import datePicker from "@/digital-components/date-picker/date-picker";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import {
|
import {
|
||||||
|
|
@ -62,29 +65,77 @@ export default {
|
||||||
return {
|
return {
|
||||||
selectedDate: null,
|
selectedDate: null,
|
||||||
mockSelectableDatesData: [
|
mockSelectableDatesData: [
|
||||||
{ year: 2023, month: 4, date: 13 },
|
{ dateString: "2023-04-28", year: 2023, month: 4, date: 28 },
|
||||||
{ year: 2023, month: 4, date: 14 },
|
{ dateString: "2023-05-04", year: 2023, month: 5, date: 4 },
|
||||||
{ year: 2023, month: 4, date: 26 },
|
{ dateString: "2023-05-05", year: 2023, month: 5, date: 5 },
|
||||||
{ year: 2023, month: 5, date: 4 },
|
{ dateString: "2023-05-14", year: 2023, month: 5, date: 14 },
|
||||||
{ year: 2023, month: 5, date: 5 },
|
{ dateString: "2023-05-21", year: 2023, month: 5, date: 21 },
|
||||||
{ year: 2023, month: 5, date: 14 },
|
{ dateString: "2023-05-23", year: 2023, month: 5, date: 23 },
|
||||||
{ year: 2023, month: 5, date: 21 },
|
{ dateString: "2023-05-25", year: 2023, month: 5, date: 25 },
|
||||||
{ year: 2023, month: 5, date: 23 },
|
{ dateString: "2023-06-11", year: 2023, month: 6, date: 11 },
|
||||||
{ year: 2023, month: 5, date: 25 },
|
{ dateString: "2023-06-13", year: 2023, month: 6, date: 13 },
|
||||||
{ year: 2023, month: 6, date: 11 },
|
{ dateString: "2023-06-17", year: 2023, month: 6, date: 17 },
|
||||||
],
|
],
|
||||||
|
selectableDatesData: [],
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
|
shopTimeSlots: {
|
||||||
|
estimatedServiceMinutesMinimum: 120,
|
||||||
|
estimatedServiceMinutesMaximum: 180,
|
||||||
|
days: [
|
||||||
|
{
|
||||||
|
date: "2023-04-25",
|
||||||
|
timeSlots: [
|
||||||
|
{
|
||||||
|
id: 12001400,
|
||||||
|
startTime: "12:00:00Z",
|
||||||
|
endTime: "14:00:00Z",
|
||||||
|
offerPremium: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: "2023-04-26",
|
||||||
|
timeSlots: [
|
||||||
|
{ id: 12001400,
|
||||||
|
startTime: "12:00:00Z",
|
||||||
|
endTime: "14:00:00Z",
|
||||||
|
offerPremium: false,
|
||||||
|
},
|
||||||
|
{ id: 12001400,
|
||||||
|
startTime: "14:30:00Z",
|
||||||
|
endTime: "17:30:00Z",
|
||||||
|
offerPremium: false,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
*/
|
||||||
},
|
},
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
|
||||||
|
const getShopTimeSlotsPromise = baseMixin.methods.dispatchStoreAction(
|
||||||
|
storeActions.GET_SHOP_TIME_SLOTS,
|
||||||
|
{
|
||||||
|
startDate: "2023-01-01",
|
||||||
|
endDate: "2023-05-01",
|
||||||
|
shopAppointmentType: "ZZZZ",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "shopTimeSlots",
|
||||||
|
promise: getShopTimeSlotsPromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
@ -92,6 +143,7 @@ export default {
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
vm.shopTimeSlots = resultMap.shopTimeSlots;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -112,8 +164,43 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
// NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE?
|
// NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE?
|
||||||
},
|
},
|
||||||
getAvailableDates(startDate, endDate) {
|
async getAvailableDates(startDate, endDate) {
|
||||||
return this.mockSelectableDatesData;
|
// console.log("S- async getAvailableDates");
|
||||||
|
|
||||||
|
// USING DATES PASSED, MAKE AN API CALL
|
||||||
|
const newShopTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction(
|
||||||
|
storeActions.GET_SHOP_TIME_SLOTS,
|
||||||
|
{
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
shopAppointmentType: "ZZZZ",
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
const newShopTimeSlots = newShopTimeSlotsResponse.data;
|
||||||
|
// console.log("newShopTimeSlots ", newShopTimeSlots)
|
||||||
|
|
||||||
|
// ADD API CALL RESULTS TO EXISTING DATE DATA
|
||||||
|
const currentData = [
|
||||||
|
...this.selectableDatesData,
|
||||||
|
this.convertApiResponse(newShopTimeSlots.days),
|
||||||
|
];
|
||||||
|
|
||||||
|
// RETURN ALL THE DATE DATA (THE AGGREGATE)
|
||||||
|
return this.mockSelectableDatesData; // TODO REMOVE MOCK DATA
|
||||||
|
// return currentData;
|
||||||
|
},
|
||||||
|
convertApiResponse(responseData) {
|
||||||
|
// DATA CONVERSION
|
||||||
|
responseData?.forEach((date) => {
|
||||||
|
const dateString = date.date;
|
||||||
|
date.dateString = dateString;
|
||||||
|
const dateStringPieces = dateString.split("-");
|
||||||
|
date.year = Number(dateStringPieces[0]);
|
||||||
|
date.month = Number(dateStringPieces[1]);
|
||||||
|
date.date = Number(dateStringPieces[2]);
|
||||||
|
});
|
||||||
|
return responseData;
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
|
|
|
||||||
|
|
@ -993,6 +993,41 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getShopTimeSlots(
|
||||||
|
context,
|
||||||
|
{ startDate = "2023-01-01", endDate = "2023-05-01", shopAppointmentType = "" }
|
||||||
|
) {
|
||||||
|
const order = context.state.order;
|
||||||
|
const mockArray = [];
|
||||||
|
|
||||||
|
var payload = {
|
||||||
|
providerNumber: order.providerNumber,
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
shopAppointmentType: shopAppointmentType,
|
||||||
|
applicationName: applicationConfig.APPLICATION_NAME,
|
||||||
|
parentAccountNumber: context.getters.payment.parentAccountNumber,
|
||||||
|
carId: context.getters.vehicle.carId,
|
||||||
|
partNumbers: mockArray, // TODO: WHERE DO I GET THIS?
|
||||||
|
eon: order.eon,
|
||||||
|
provisionalReasons: mockArray, // TODO: WHERE DO I GET THIS?
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: REMOVE MOCK CALL & USE REAL CALL BELOW
|
||||||
|
return globalMethods.callMockHttpClient({
|
||||||
|
method: endpoints.GetShopTimeSlots.method,
|
||||||
|
endpoint: endpoints.GetShopTimeSlots.mockUrl,
|
||||||
|
payload: payload,
|
||||||
|
});
|
||||||
|
// TODO: RESTORE THIS
|
||||||
|
// return globalMethods.callHttpClient({
|
||||||
|
// method: endpoints.GetShopTimeSlots.method,
|
||||||
|
// endpoint: endpoints.GetShopTimeSlots.url,
|
||||||
|
// payload: payload,
|
||||||
|
// logApiCall: false,
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
|
||||||
// Session API Actions
|
// Session API Actions
|
||||||
saveSession(context) {
|
saveSession(context) {
|
||||||
const vehicle = context.getters.vehicle;
|
const vehicle = context.getters.vehicle;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue