CSR-1137 | Integrate shop-time-slots endpoint
This commit is contained in:
parent
04a09f6fa2
commit
881004fc9b
5 changed files with 64 additions and 37 deletions
|
|
@ -108,7 +108,10 @@ const endpoints = {
|
||||||
},
|
},
|
||||||
GetShopTimeSlots: {
|
GetShopTimeSlots: {
|
||||||
url: "/schedule/api/v1/schedule/shop-time-slots",
|
url: "/schedule/api/v1/schedule/shop-time-slots",
|
||||||
mockUrl: "https://mockey.qa.sagaws.net/service/shop-time-slots", // TODO: REMOVE MOCKURL
|
method: "POST",
|
||||||
|
},
|
||||||
|
GetMobileTimeSlots: {
|
||||||
|
url: "/schedule/api/v1/schedule/mobile-time-slots",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
GetMobileEarlyBirdFee: {
|
GetMobileEarlyBirdFee: {
|
||||||
|
|
|
||||||
|
|
@ -245,9 +245,10 @@ export default {
|
||||||
|
|
||||||
let myPromise = new Promise((resolve, reject) => {
|
let myPromise = new Promise((resolve, reject) => {
|
||||||
const response = config.customSelectableDatesCallback(
|
const response = config.customSelectableDatesCallback(
|
||||||
initialViewStartDate,
|
initialViewStartDate.toISOString().split("T")[0],
|
||||||
initialViewEndDate,
|
initialViewEndDate.toISOString().split("T")[0],
|
||||||
store.getters.order.serviceLocation.appointmentType
|
store.getters.order.serviceLocation.appointmentType,
|
||||||
|
store.getters.order.serviceLocation.provider.providerNumber
|
||||||
);
|
);
|
||||||
resolve(response);
|
resolve(response);
|
||||||
});
|
});
|
||||||
|
|
@ -309,7 +310,6 @@ export default {
|
||||||
this.hideSomeDaysForInitialView = config.hideSomeDaysForInitialView;
|
this.hideSomeDaysForInitialView = config.hideSomeDaysForInitialView;
|
||||||
const hideSecondMonth = config.hideSecondMonth;
|
const hideSecondMonth = config.hideSecondMonth;
|
||||||
const direction = config.calendarViewDirection;
|
const direction = config.calendarViewDirection;
|
||||||
|
|
||||||
const monthsAfterToLoadOffset = 12;
|
const monthsAfterToLoadOffset = 12;
|
||||||
const monthsBeforeToLoadOffset = 36;
|
const monthsBeforeToLoadOffset = 36;
|
||||||
config.initialShopTimeSlotsResponse.days.forEach((selectableDate) => {
|
config.initialShopTimeSlotsResponse.days.forEach((selectableDate) => {
|
||||||
|
|
@ -526,7 +526,8 @@ export default {
|
||||||
const moreSelectableDates = await this.customSelectableDatesCallback(
|
const moreSelectableDates = await this.customSelectableDatesCallback(
|
||||||
monthStart,
|
monthStart,
|
||||||
monthEnd,
|
monthEnd,
|
||||||
this.$store.getters.order.serviceLocation.appointmentType
|
this.$store.getters.order.serviceLocation.appointmentType,
|
||||||
|
this.$store.getters.order.serviceLocation.provider.providerNumber
|
||||||
);
|
);
|
||||||
moreSelectableDates.days.forEach((selectableDate) => {
|
moreSelectableDates.days.forEach((selectableDate) => {
|
||||||
const index = this.selectableDatesData.findIndex(
|
const index = this.selectableDatesData.findIndex(
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ import store from "@/store";
|
||||||
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
||||||
defineRule("time-slot-selection-required", required(errorMessages.DATE_REQUIRED));
|
defineRule("time-slot-selection-required", required(errorMessages.DATE_REQUIRED));
|
||||||
|
|
||||||
const getAvailableDates = async (startDate, endDate, appointmentType) => {
|
const getAvailableDates = async (startDate, endDate, appointmentType, providerNumber) => {
|
||||||
// USING DATES PASSED, MAKE AN API CALL
|
// USING DATES PASSED, MAKE AN API CALL
|
||||||
const newShopTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction(
|
const newShopTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction(
|
||||||
storeActions.GET_SHOP_TIME_SLOTS,
|
storeActions.GET_SHOP_TIME_SLOTS,
|
||||||
|
|
@ -89,6 +89,7 @@ const getAvailableDates = async (startDate, endDate, appointmentType) => {
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
shopAppointmentType: appointmentType,
|
shopAppointmentType: appointmentType,
|
||||||
|
providerNumber: providerNumber,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
@ -152,7 +153,6 @@ export default {
|
||||||
const alertReasonsPromise = locationAlerts.methods.loadInitialData(
|
const alertReasonsPromise = locationAlerts.methods.loadInitialData(
|
||||||
store.getters.order.serviceLocation.zipCodeCtu
|
store.getters.order.serviceLocation.zipCodeCtu
|
||||||
);
|
);
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
|
|
@ -241,7 +241,8 @@ export default {
|
||||||
const newShopTimeSlots = await getAvailableDates(
|
const newShopTimeSlots = await getAvailableDates(
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
this.appointmentType
|
this.appointmentType,
|
||||||
|
this.$store.getters.order.serviceLocation.provider.providerNumber
|
||||||
);
|
);
|
||||||
// ADD API CALL RESULTS TO EXISTING DATE DATA
|
// ADD API CALL RESULTS TO EXISTING DATE DATA
|
||||||
this.selectableDatesData.days = this.selectableDatesData.days.concat(
|
this.selectableDatesData.days = this.selectableDatesData.days.concat(
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,11 @@ export default {
|
||||||
// This conversion ensures we don't get get GMT induced date changes
|
// This conversion ensures we don't get get GMT induced date changes
|
||||||
const dateObject = new Date(`${this.dateAndTimeSlotData.dateString}T00:00:00`);
|
const dateObject = new Date(`${this.dateAndTimeSlotData.dateString}T00:00:00`);
|
||||||
// Ex: Tuesday, April 22
|
// Ex: Tuesday, April 22
|
||||||
return dateObject.toLocaleDateString("en-us", {weekday:"long", month:"long", day:"numeric"});
|
return dateObject.toLocaleDateString("en-us", {
|
||||||
|
weekday: "long",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
availableTimeSlots() {
|
availableTimeSlots() {
|
||||||
if (this.dateAndTimeSlotData === null) {
|
if (this.dateAndTimeSlotData === null) {
|
||||||
|
|
@ -240,7 +244,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAvailableTimeSlotsForDropOff(timeSlotsForSelectedDate) {
|
getAvailableTimeSlotsForDropOff(timeSlotsForSelectedDate) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
value: timeSlotsForSelectedDate[0].id,
|
value: timeSlotsForSelectedDate[0].id,
|
||||||
buttonLabel: this.dropoffButtonText,
|
buttonLabel: this.dropoffButtonText,
|
||||||
|
|
@ -248,7 +252,7 @@ export default {
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
getAvailableTimeSlotsForMobile(timeSlotsForSelectedDate) {
|
getAvailableTimeSlotsForMobile(timeSlotsForSelectedDate) {
|
||||||
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
|
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
|
||||||
const readableTime = `${this.getDisplayTextForMilitaryTime(
|
const readableTime = `${this.getDisplayTextForMilitaryTime(
|
||||||
timeSlot.startTime
|
timeSlot.startTime
|
||||||
)} - ${this.getDisplayTextForMilitaryTime(timeSlot.endTime)}`;
|
)} - ${this.getDisplayTextForMilitaryTime(timeSlot.endTime)}`;
|
||||||
|
|
@ -262,7 +266,9 @@ export default {
|
||||||
const hasPremiumPartAvailable =
|
const hasPremiumPartAvailable =
|
||||||
this.premiumAppointmentFee?.partType === PREMIUM_FEE_PART_TYPE;
|
this.premiumAppointmentFee?.partType === PREMIUM_FEE_PART_TYPE;
|
||||||
if (isPremiumTimeSlot && hasPremiumPartAvailable) {
|
if (isPremiumTimeSlot && hasPremiumPartAvailable) {
|
||||||
availableTimeSlots.unshift(this.getPremiumAppointmentTimeSlot(timeSlotsForSelectedDate[0]));
|
availableTimeSlots.unshift(
|
||||||
|
this.getPremiumAppointmentTimeSlot(timeSlotsForSelectedDate[0])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return availableTimeSlots;
|
return availableTimeSlots;
|
||||||
|
|
@ -278,7 +284,7 @@ export default {
|
||||||
additionalButtonData: {
|
additionalButtonData: {
|
||||||
isPremiumAppointment: true,
|
isPremiumAppointment: true,
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) {
|
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) {
|
||||||
const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length;
|
const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length;
|
||||||
|
|
|
||||||
|
|
@ -1116,39 +1116,55 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getShopTimeSlots(
|
getShopTimeSlots(context, { startDate, endDate, shopAppointmentType, providerNumber }) {
|
||||||
context,
|
|
||||||
{ startDate = "2023-01-01", endDate = "2023-05-01", shopAppointmentType = "" }
|
|
||||||
) {
|
|
||||||
const order = context.state.order;
|
const order = context.state.order;
|
||||||
const mockArray = [];
|
const vehicle = context.state.order.vehicle;
|
||||||
|
let partNumbers = [
|
||||||
|
...(order.lineItems.supportingItems ?? []),
|
||||||
|
...(order.lineItems.vaps ?? []),
|
||||||
|
...getFlattenedArrayOfLineItemsWithChildParts(order.lineItems.glassParts),
|
||||||
|
];
|
||||||
|
partNumbers = partNumbers.map((lineItem) => {
|
||||||
|
return lineItem.partNumber;
|
||||||
|
});
|
||||||
|
const glassPieces = order.damage.glassToReplace ?? [];
|
||||||
var payload = {
|
var payload = {
|
||||||
providerNumber: order.providerNumber,
|
providerNumber: providerNumber,
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
shopAppointmentType: shopAppointmentType,
|
shopAppointmentType: shopAppointmentType,
|
||||||
applicationName: applicationConfig.APPLICATION_NAME,
|
applicationName: "Safelite.com funnel",
|
||||||
parentAccountNumber: context.getters.payment.parentAccountNumber,
|
parentAccountNumber: context.getters.payment.parentAccountNumber,
|
||||||
carId: context.getters.vehicle.carId,
|
carId: vehicle.carId,
|
||||||
partNumbers: mockArray, // TODO: WHERE DO I GET THIS?
|
partNumbers: partNumbers,
|
||||||
|
glassPieces: glassPieces,
|
||||||
eon: order.eon,
|
eon: order.eon,
|
||||||
provisionalReasons: mockArray, // TODO: WHERE DO I GET THIS?
|
coverage: {
|
||||||
|
status: "",
|
||||||
|
deductible: 0,
|
||||||
|
additionalAuthFlag: "",
|
||||||
|
},
|
||||||
|
partSelection: {
|
||||||
|
// TODO: Provisional booking will utilize these fields
|
||||||
|
hasAnsweredPartQuestions: false,
|
||||||
|
hasAnsweredMoldingQuestions: false,
|
||||||
|
hasAnsweredCapabilityQuestions: false,
|
||||||
|
hasManuallySelectedParts: false,
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
year: vehicle.year,
|
||||||
|
make: vehicle.make,
|
||||||
|
model: vehicle.model,
|
||||||
|
style: vehicle.style,
|
||||||
|
vin: vehicle.vin,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
return globalMethods.callHttpClient({
|
||||||
// TODO: REMOVE MOCK CALL & USE REAL CALL BELOW
|
|
||||||
return globalMethods.callMockHttpClient({
|
|
||||||
method: endpoints.GetShopTimeSlots.method,
|
method: endpoints.GetShopTimeSlots.method,
|
||||||
endpoint: endpoints.GetShopTimeSlots.mockUrl,
|
endpoint: endpoints.GetShopTimeSlots.url,
|
||||||
payload: payload,
|
payload: payload,
|
||||||
|
logApiCall: false,
|
||||||
});
|
});
|
||||||
// TODO: RESTORE THIS
|
|
||||||
// return globalMethods.callHttpClient({
|
|
||||||
// method: endpoints.GetShopTimeSlots.method,
|
|
||||||
// endpoint: endpoints.GetShopTimeSlots.url,
|
|
||||||
// payload: payload,
|
|
||||||
// logApiCall: false,
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
getMobileEarlyBirdFee(context) {
|
getMobileEarlyBirdFee(context) {
|
||||||
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
||||||
|
|
@ -1863,7 +1879,7 @@ function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||||
|
|
||||||
function getFlattenedArrayOfLineItemsWithChildParts(lineItems) {
|
function getFlattenedArrayOfLineItemsWithChildParts(lineItems) {
|
||||||
let flattenedArray = [];
|
let flattenedArray = [];
|
||||||
lineItems.forEach((lineItem) => {
|
lineItems?.forEach((lineItem) => {
|
||||||
flattenedArray.push(lineItem);
|
flattenedArray.push(lineItem);
|
||||||
if (lineItem.childParts) {
|
if (lineItem.childParts) {
|
||||||
flattenedArray = [
|
flattenedArray = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue