Service Location
This commit is contained in:
parent
9a3318b3fd
commit
964b06744f
8 changed files with 110 additions and 25 deletions
|
|
@ -2,42 +2,45 @@ import { storeActions } from "@/constants/store-actions";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
export async function getPricedMobileFeePart(serviceZipCode) {
|
export async function getPricedMobileFeePart(serviceZipCode, pageNameToLog) {
|
||||||
if (!serviceZipCode) {
|
if (!serviceZipCode) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
const zipCodeData = await baseMixin.methods.getZipCodeData(serviceZipCode);
|
const zipCodeData = await baseMixin.methods.getZipCodeData(serviceZipCode, pageNameToLog);
|
||||||
|
|
||||||
// Get the Mobile Fee Part
|
// Get the Mobile Fee Part
|
||||||
const mobileFeePart = await baseMixin.methods.dispatchStoreAction(
|
const mobileFeePart = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.GET_MOBILE_FEE_PART,
|
storeActions.GET_MOBILE_FEE_PART,
|
||||||
null,
|
null,
|
||||||
|
pageNameToLog,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the Mobile Fee Part Price
|
// Get the Mobile Fee Part Price
|
||||||
const pricingResults = await baseMixin.methods.dispatchStoreAction(
|
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
availableLineItems: [mobileFeePart.data],
|
availableLineItems: [mobileFeePart.data],
|
||||||
serviceZipCode: serviceZipCode,
|
serviceZipCode: serviceZipCode,
|
||||||
serviceZipCodeCtu: zipCodeData.zipCodeCtu,
|
serviceZipCodeCtu: zipCodeData.zipCodeCtu,
|
||||||
},
|
},
|
||||||
|
pageNameToLog,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
return Promise.resolve(pricingResults[0]);
|
return Promise.resolve(pricingResults[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getServiceabilityDetails(serviceZipCode, lineItems) {
|
export async function getServiceabilityDetails(serviceZipCode, lineItems, pageNameToLog) {
|
||||||
// Get the Mobile Fee Part
|
// Get the Mobile Fee Part
|
||||||
const serviceabilityDetails = await baseMixin.methods.dispatchStoreAction(
|
const serviceabilityDetails = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.GET_SERVICEABILITY_DETAILS,
|
storeActions.GET_SERVICEABILITY_DETAILS,
|
||||||
{
|
{
|
||||||
serviceZipCode: serviceZipCode,
|
serviceZipCode: serviceZipCode,
|
||||||
lineItems: lineItems,
|
lineItems: lineItems,
|
||||||
},
|
},
|
||||||
|
pageNameToLog,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -51,7 +54,7 @@ export async function getAvailabilityRating(
|
||||||
providerNumber
|
providerNumber
|
||||||
) {
|
) {
|
||||||
// For a given shop provider number and date range, get the appointment time slots available
|
// For a given shop provider number and date range, get the appointment time slots available
|
||||||
const shopTimeSlots = await baseMixin.methods.dispatchStoreAction(
|
const shopTimeSlots = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.GET_SHOP_TIME_SLOTS,
|
storeActions.GET_SHOP_TIME_SLOTS,
|
||||||
{
|
{
|
||||||
providerNumber: providerNumber,
|
providerNumber: providerNumber,
|
||||||
|
|
@ -59,6 +62,7 @@ export async function getAvailabilityRating(
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
shopAppointmentType: shopAppointmentType,
|
shopAppointmentType: shopAppointmentType,
|
||||||
},
|
},
|
||||||
|
"service-location",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,47 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actionName === mockStoreActionGetShopTimeSlots) {
|
||||||
|
if (request.providerNumber == "0000001") {
|
||||||
|
return Promise.resolve(mockGetShopTimeSlotsGoodAvailability);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(mockGetShopTimeSlotsLowAvailability);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
dispatchStoreActionWithLogging: jest.fn().mockImplementation((actionName, request) => {
|
||||||
|
if (actionName === mockStoreActionGetMobileFeePart) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: {
|
||||||
|
partNumber: "MOBILE FEE",
|
||||||
|
description: "MOBILE FEE",
|
||||||
|
partType: "FEE",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actionName === mockStoreActionPriceOrderItemsAndSaveServerData) {
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
partNumber: "MOBILE FEE",
|
||||||
|
description: "MOBILE FEE",
|
||||||
|
partType: "FEE",
|
||||||
|
laborAmount: 49.99,
|
||||||
|
sellingPrice: 0,
|
||||||
|
kitPrice: 0,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actionName === mockStoreActionGetServiceabilityDetails) {
|
||||||
|
return Promise.resolve({
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
|
isRecalibrationServiceableInshop: true,
|
||||||
|
isGlassServiceableMobile: true,
|
||||||
|
isRecalibrationServiceableMobile: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (actionName === mockStoreActionGetShopTimeSlots) {
|
if (actionName === mockStoreActionGetShopTimeSlots) {
|
||||||
if (request.providerNumber == "0000001") {
|
if (request.providerNumber == "0000001") {
|
||||||
return Promise.resolve(mockGetShopTimeSlotsGoodAvailability);
|
return Promise.resolve(mockGetShopTimeSlotsGoodAvailability);
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,8 @@ export default {
|
||||||
) {
|
) {
|
||||||
// Validate the Zip Code
|
// Validate the Zip Code
|
||||||
const zipCodeData = await this.getZipCodeData(
|
const zipCodeData = await this.getZipCodeData(
|
||||||
this.internalModel.addressQuestions.zipCode
|
this.internalModel.addressQuestions.zipCode,
|
||||||
|
"service-location"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!zipCodeData.isValid) {
|
if (!zipCodeData.isValid) {
|
||||||
|
|
@ -238,10 +239,17 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
// retrieve mobile fee part
|
// retrieve mobile fee part
|
||||||
const serviceZipCode = this.internalModel.addressQuestions.zipCode;
|
const serviceZipCode = this.internalModel.addressQuestions.zipCode;
|
||||||
const mobileFeePart = await getPricedMobileFeePart(serviceZipCode);
|
const mobileFeePart = await getPricedMobileFeePart(
|
||||||
|
serviceZipCode,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
// retrieve serviceability details
|
// retrieve serviceability details
|
||||||
const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode);
|
const serviceabilityDetails = await getServiceabilityDetails(
|
||||||
|
serviceZipCode,
|
||||||
|
null,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
// update content related to service zip code
|
// update content related to service zip code
|
||||||
this.$emit("updated-mobile-fee-part", mobileFeePart);
|
this.$emit("updated-mobile-fee-part", mobileFeePart);
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,15 @@ export default {
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
|
||||||
const serviceZipCode = store.getters.order.serviceLocation.zipCode;
|
const serviceZipCode = store.getters.order.serviceLocation.zipCode;
|
||||||
const getZipCodeData = baseMixin.methods.getZipCodeData(serviceZipCode);
|
const getZipCodeData = baseMixin.methods.getZipCodeData(serviceZipCode, "service-location");
|
||||||
|
|
||||||
const serviceabilityDetailsPromise = getServiceabilityDetails(serviceZipCode);
|
const serviceabilityDetailsPromise = getServiceabilityDetails(
|
||||||
|
serviceZipCode,
|
||||||
|
null,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode);
|
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode, "service-location");
|
||||||
|
|
||||||
const shopQuestionInitialDataPromise = shopQuestion.methods.loadInitialData(serviceZipCode);
|
const shopQuestionInitialDataPromise = shopQuestion.methods.loadInitialData(serviceZipCode);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,10 @@ export default {
|
||||||
if (this.internalModel.zipCode !== this.modelValue.zipCode) {
|
if (this.internalModel.zipCode !== this.modelValue.zipCode) {
|
||||||
this.resetAlerts();
|
this.resetAlerts();
|
||||||
|
|
||||||
const zipCodeData = await this.getZipCodeData(this.internalModel.zipCode);
|
const zipCodeData = await this.getZipCodeData(
|
||||||
|
this.internalModel.zipCode,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
if (!zipCodeData.isValid) {
|
if (!zipCodeData.isValid) {
|
||||||
this.displayInvalidZipAlert = true;
|
this.displayInvalidZipAlert = true;
|
||||||
|
|
@ -144,10 +147,17 @@ export default {
|
||||||
|
|
||||||
// retrieve mobile fee part
|
// retrieve mobile fee part
|
||||||
const serviceZipCode = this.internalModel.zipCode;
|
const serviceZipCode = this.internalModel.zipCode;
|
||||||
const mobileFeePart = await getPricedMobileFeePart(serviceZipCode);
|
const mobileFeePart = await getPricedMobileFeePart(
|
||||||
|
serviceZipCode,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
// retrieve serviceability details
|
// retrieve serviceability details
|
||||||
const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode);
|
const serviceabilityDetails = await getServiceabilityDetails(
|
||||||
|
serviceZipCode,
|
||||||
|
null,
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
|
|
||||||
// update content related to service zip code
|
// update content related to service zip code
|
||||||
this.$emit("updated-mobile-fee-part", mobileFeePart);
|
this.$emit("updated-mobile-fee-part", mobileFeePart);
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,13 @@ export default {
|
||||||
return this.loadData(serviceZipCode);
|
return this.loadData(serviceZipCode);
|
||||||
},
|
},
|
||||||
loadData(serviceZipCode) {
|
loadData(serviceZipCode) {
|
||||||
return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDERS, {
|
return baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
serviceZipCode: serviceZipCode,
|
storeActions.GET_PROVIDERS,
|
||||||
});
|
{
|
||||||
|
serviceZipCode: serviceZipCode,
|
||||||
|
},
|
||||||
|
"service-location"
|
||||||
|
);
|
||||||
},
|
},
|
||||||
initializeComponent(shopQuestionInitialData) {
|
initializeComponent(shopQuestionInitialData) {
|
||||||
this.shopProviders = shopQuestionInitialData.shopProviders;
|
this.shopProviders = shopQuestionInitialData.shopProviders;
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,11 @@ export default {
|
||||||
const footerInfoBox = document.querySelector(".footer#infoBox");
|
const footerInfoBox = document.querySelector(".footer#infoBox");
|
||||||
return footerInfoBox ? footerInfoBox.offsetHeight : 0;
|
return footerInfoBox ? footerInfoBox.offsetHeight : 0;
|
||||||
},
|
},
|
||||||
async getZipCodeData(zipCode) {
|
async getZipCodeData(zipCode, pageNameToLog = null) {
|
||||||
const pageName = this.$options?.name;
|
const pageName = pageNameToLog ?? this.$options?.name;
|
||||||
|
if (pageName == null) {
|
||||||
|
console.log("Missed a spot.");
|
||||||
|
}
|
||||||
|
|
||||||
const serviceZipValidationResponse = await this.dispatchStoreActionWithLogging(
|
const serviceZipValidationResponse = await this.dispatchStoreActionWithLogging(
|
||||||
storeActions.VALIDATE_ZIP,
|
storeActions.VALIDATE_ZIP,
|
||||||
|
|
|
||||||
|
|
@ -1235,7 +1235,7 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getMobileFeePart(context) {
|
getMobileFeePart(context, { pageNameToLog }) {
|
||||||
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
||||||
const parentAccountNumber = context.getters.payment.parentAccountNumber;
|
const parentAccountNumber = context.getters.payment.parentAccountNumber;
|
||||||
const billToAccountNumber = 87291; // TODO: MAKE THIS REAL
|
const billToAccountNumber = 87291; // TODO: MAKE THIS REAL
|
||||||
|
|
@ -1243,10 +1243,12 @@ export const actions = {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetMobileFeePart.method,
|
method: endpoints.GetMobileFeePart.method,
|
||||||
endpoint: `${endpoints.GetMobileFeePart.url}/${damageType}/${parentAccountNumber}/${billToAccountNumber}`,
|
endpoint: `${endpoints.GetMobileFeePart.url}/${damageType}/${parentAccountNumber}/${billToAccountNumber}`,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getServiceabilityDetails(context, { serviceZipCode }) {
|
getServiceabilityDetails(context, { payload: { serviceZipCode }, pageNameToLog }) {
|
||||||
const lineItemsWithOnlyPartNumbers = context.getters.order.lineItems.supportingItems.map(
|
const lineItemsWithOnlyPartNumbers = context.getters.order.lineItems.supportingItems.map(
|
||||||
(lineItem) => ({
|
(lineItem) => ({
|
||||||
partNumber: lineItem.partNumber,
|
partNumber: lineItem.partNumber,
|
||||||
|
|
@ -1270,16 +1272,20 @@ export const actions = {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetServiceabilityDetails.method,
|
method: endpoints.GetServiceabilityDetails.method,
|
||||||
endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&carId=${carId}&${lineItems}&${glassPieces}`,
|
endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&carId=${carId}&${lineItems}&${glassPieces}`,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getProviders(context, { serviceZipCode }) {
|
getProviders(context, { payload: { serviceZipCode }, pageNameToLog }) {
|
||||||
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
||||||
const shopRadiusInMiles = 100;
|
const shopRadiusInMiles = 100;
|
||||||
|
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetProviders.method,
|
method: endpoints.GetProviders.method,
|
||||||
endpoint: `${endpoints.GetProviders.url}/${serviceZipCode}/${damageType}/${shopRadiusInMiles}`,
|
endpoint: `${endpoints.GetProviders.url}/${serviceZipCode}/${damageType}/${shopRadiusInMiles}`,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1336,7 +1342,10 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getShopTimeSlots(context, { startDate, endDate, shopAppointmentType, providerNumber }) {
|
getShopTimeSlots(
|
||||||
|
context,
|
||||||
|
{ payload: { startDate, endDate, shopAppointmentType, providerNumber }, pageNameToLog }
|
||||||
|
) {
|
||||||
const order = context.state.order;
|
const order = context.state.order;
|
||||||
const vehicle = context.state.order.vehicle;
|
const vehicle = context.state.order.vehicle;
|
||||||
|
|
||||||
|
|
@ -1391,6 +1400,8 @@ export const actions = {
|
||||||
method: endpoints.GetShopTimeSlots.method,
|
method: endpoints.GetShopTimeSlots.method,
|
||||||
endpoint: endpoints.GetShopTimeSlots.url,
|
endpoint: endpoints.GetShopTimeSlots.url,
|
||||||
payload: payload,
|
payload: payload,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
additionalSuccessEventDataHandler: (response) =>
|
additionalSuccessEventDataHandler: (response) =>
|
||||||
getTimeSlotsAdditionalEventData(
|
getTimeSlotsAdditionalEventData(
|
||||||
response.data.provisionalTriggers,
|
response.data.provisionalTriggers,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue