Merge branch 'develop' into feature/CSR-886

This commit is contained in:
Adam Caouette 2023-06-09 10:07:46 -04:00
commit 9593341c86
5 changed files with 141 additions and 34 deletions

View file

@ -26,7 +26,7 @@ module.exports = {
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
coverageThreshold: { coverageThreshold: {
global: { global: {
statements: 78, statements: 77,
// Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90
}, },
}, },

View file

@ -36,8 +36,12 @@ export default {
}, },
}, },
methods: { methods: {
loadInitialData(zipCodeCtu) { loadInitialData(serviceLocationCtu, providerCtu) {
return getAlertReasons(zipCodeCtu); let ctuToUse = serviceLocationCtu;
if (providerCtu) {
ctuToUse = providerCtu;
}
return getAlertReasons(ctuToUse);
}, },
initializeComponent(initialData) { initializeComponent(initialData) {
this.alertReasons = initialData; this.alertReasons = initialData;

View file

@ -50,6 +50,7 @@ import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer";
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
import { processIfStatements } from "@/helpers/cms-content-helper";
import datePicker from "@/digital-components/date-picker/date-picker"; import datePicker from "@/digital-components/date-picker/date-picker";
import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts"; import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts";
import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question"; import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question";
@ -67,7 +68,7 @@ import {
getRouterLinkRouteFromCopy, getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy, getRouterLinkDisplayTextFromCopy,
} from "@/helpers/cms-content-helper"; } from "@/helpers/cms-content-helper";
import { AppointmentTypeStrings } from "@/constants/schedule-constants"; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import store from "@/store"; import store from "@/store";
@ -146,7 +147,8 @@ export default {
}); });
const alertReasonsPromise = locationAlerts.methods.loadInitialData( const alertReasonsPromise = locationAlerts.methods.loadInitialData(
store.getters.order.serviceLocation.zipCodeCtu store.getters.order.serviceLocation.zipCodeCtu,
store.getters.order.serviceLocation.provider?.address?.zipCtu
); );
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
@ -227,6 +229,7 @@ export default {
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy, getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy, getRouterLinkDisplayTextFromCopy,
processIfStatements,
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
const serviceLocation = store.getters.order.serviceLocation; const serviceLocation = store.getters.order.serviceLocation;
const serviceLocationPreReqs = const serviceLocationPreReqs =
@ -335,7 +338,8 @@ export default {
backButtonAction() { backButtonAction() {
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async forwardButtonAction() { forwardButtonAction() {
this.updateSupportingItems();
this.dispatchStoreAction( this.dispatchStoreAction(
this.storeActions.SAVE_SCHEDULE, this.storeActions.SAVE_SCHEDULE,
this.appointmentDateAndTime, this.appointmentDateAndTime,
@ -343,6 +347,51 @@ export default {
); );
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
}, },
updateSupportingItems() {
const supportingItems = store.getters.lineItems.supportingItems;
// if we have a premium fee(early bird), then save/update supporting items
if (
this.appointmentType === AppointmentTypeStrings.MOBILE &&
this.selectedTimeSlotData?.isPremiumAppointment
) {
const earlyBirdIndex = supportingItems.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE
);
if (earlyBirdIndex >= 0) {
supportingItems[earlyBirdIndex].laborAmount =
this.mobilePremiumAppointmentFee.laborAmount;
supportingItems[earlyBirdIndex].selingPrice =
this.mobilePremiumAppointmentFee.selingPrice;
supportingItems[earlyBirdIndex].kitPrice =
this.mobilePremiumAppointmentFee.kitPrice;
} else {
supportingItems.push(this.mobilePremiumAppointmentFee);
}
this.dispatchStoreAction(
this.storeActions.SAVE_SUPPORTING_ITEMS,
supportingItems,
false
);
} else {
// if it's not a mobile and/or premium early bird, then make sure we remove any that may have been added
const removeEarlyBirdIndex = supportingItems.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE
);
if (removeEarlyBirdIndex >= 0) {
supportingItems.splice(removeEarlyBirdIndex, 1);
this.dispatchStoreAction(
this.storeActions.SAVE_SUPPORTING_ITEMS,
supportingItems,
false
);
}
}
},
}, },
watch: { watch: {
selectedDate(newValue, oldValue) { selectedDate(newValue, oldValue) {

View file

@ -138,7 +138,7 @@ export default {
data() { data() {
return { return {
streetAddress: this.getServiceAddressFromStore(), streetAddress: this.getServiceAddressFromStore(),
apartmentNumberOrBusinessName: "", apartmentNumberOrBusinessName: this.getServiceAddress2FromStore(),
city: this.getServiceCityFromStore(), city: this.getServiceCityFromStore(),
state: this.getServiceStateFromStore(), state: this.getServiceStateFromStore(),
zipCode: this.getServiceZipCodeFromStore(), zipCode: this.getServiceZipCodeFromStore(),
@ -339,6 +339,9 @@ export default {
getServiceAddressFromStore() { getServiceAddressFromStore() {
return store.getters.order.serviceLocation.address; return store.getters.order.serviceLocation.address;
}, },
getServiceAddress2FromStore() {
return store.getters.order.serviceLocation.address2;
},
getServiceCityFromStore() { getServiceCityFromStore() {
return store.getters.order.serviceLocation.city; return store.getters.order.serviceLocation.city;
}, },
@ -394,6 +397,7 @@ export default {
city: this.selectedProvider?.address?.city, city: this.selectedProvider?.address?.city,
state: this.selectedProvider?.address?.state, state: this.selectedProvider?.address?.state,
zip: this.selectedProvider?.address?.zipCode, zip: this.selectedProvider?.address?.zipCode,
zipCtu: this.selectedProvider?.address?.zipCodeCtu,
}, },
}, },
}, },

View file

@ -11,7 +11,7 @@ import { damageLocationsSelected } from "@/constants/damage-locations-selected";
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import router from "@/router"; import router from "@/router";
import { deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js"; import { deleteFunnelCookie } from "@/helpers/heritage-integration/cookie-helper.js";
import { AppointmentTypeStrings } from "@/constants/schedule-constants"; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants";
// Export State // Export State
const getDefaultState = () => { const getDefaultState = () => {
@ -264,6 +264,8 @@ export const mutations = {
serviceLocationInfo.provider?.address?.state; serviceLocationInfo.provider?.address?.state;
state.order.serviceLocation.provider.address.zip = state.order.serviceLocation.provider.address.zip =
serviceLocationInfo.provider?.address?.zip; serviceLocationInfo.provider?.address?.zip;
state.order.serviceLocation.provider.address.zipCtu =
serviceLocationInfo.provider?.address?.zipCtu;
} }
}, },
updateSchedule(state, scheduleInfo) { updateSchedule(state, scheduleInfo) {
@ -349,6 +351,17 @@ export const mutations = {
state.order.schedule.endTime = null; state.order.schedule.endTime = null;
state.order.schedule.routeCode = null; state.order.schedule.routeCode = null;
state.order.schedule.jobMaxMinutes = null; state.order.schedule.jobMaxMinutes = null;
//early bird fee used on schedule page also needs reset when schedule is reset
const supportingItems = state.order.lineItems.supportingItems;
const removeEarlyBirdIndex = supportingItems.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE
);
if (removeEarlyBirdIndex >= 0) {
supportingItems.splice(removeEarlyBirdIndex, 1);
state.order.lineItems.supportingItems = supportingItems;
}
}, },
resetState(state) { resetState(state) {
Object.assign(state, getDefaultState()); Object.assign(state, getDefaultState());
@ -407,18 +420,20 @@ export const mutations = {
state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems; state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems;
state.order.lineItems.vaps = sessionInformation.order.lineItems.vaps; state.order.lineItems.vaps = sessionInformation.order.lineItems.vaps;
state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData; state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData;
state.order.payment.parentAccountNumber = state.order.payment.parentAccountNumber =
sessionInformation.order.payment.parentAccountNumber; sessionInformation.order.payment.parentAccountNumber;
(state.order.serviceLocation.address =
sessionInformation.order.serviceLocation.streetAddress), state.order.serviceLocation.address =
(state.order.serviceLocation.address2 = sessionInformation.order.serviceLocation.streetAddress;
sessionInformation.order.serviceLocation.address2), state.order.serviceLocation.address2 =
(state.order.serviceLocation.city = sessionInformation.order.serviceLocation.city), sessionInformation.order.serviceLocation.streetAddress2;
(state.order.serviceLocation.state = sessionInformation.order.serviceLocation.state), state.order.serviceLocation.city = sessionInformation.order.serviceLocation.city;
(state.order.serviceLocation.zipCode = state.order.serviceLocation.state = sessionInformation.order.serviceLocation.state;
sessionInformation.order.serviceLocation.zipCode), state.order.serviceLocation.zipCode = sessionInformation.order.serviceLocation.zipCode;
(state.order.serviceLocation.zipCodeCtu = state.order.serviceLocation.zipCodeCtu =
sessionInformation.order.serviceLocation.zipCodeCtu); sessionInformation.order.serviceLocation.zipCodeCtu;
state.order.serviceLocation.appointmentType = state.order.serviceLocation.appointmentType =
sessionInformation.order.serviceLocation.appointmentType; sessionInformation.order.serviceLocation.appointmentType;
state.order.serviceLocation.isVehicleProtected = state.order.serviceLocation.isVehicleProtected =
@ -1345,6 +1360,7 @@ export const actions = {
city: order.serviceLocation.provider?.address?.city, city: order.serviceLocation.provider?.address?.city,
state: order.serviceLocation.provider?.address?.state, state: order.serviceLocation.provider?.address?.state,
zip: order.serviceLocation.provider?.address?.zip, zip: order.serviceLocation.provider?.address?.zip,
zipCtu: order.serviceLocation.provider?.address?.zipCtu,
}, },
}, },
}, },
@ -1406,6 +1422,7 @@ export const actions = {
if (context.state.order.eon && context.state.order.eon != response.data.eon) { if (context.state.order.eon && context.state.order.eon != response.data.eon) {
context.commit(storeMutations.RESET_STATE); context.commit(storeMutations.RESET_STATE);
} }
context.commit( context.commit(
storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION,
response.data response.data
@ -1799,7 +1816,6 @@ export const actions = {
`&${availableLineItemsFormattedForRequest}`; `&${availableLineItemsFormattedForRequest}`;
const lineItemServerData = context.getters.order.lineItems.serverData; const lineItemServerData = context.getters.order.lineItems.serverData;
if (lineItemServerData) { if (lineItemServerData) {
queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`; queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`;
} }
@ -2070,6 +2086,40 @@ async function validateAppointment(context, order) {
}, },
false false
); );
if (newTimeSlotsResponse?.data.days?.length === 0) {
context.commit(storeMutations.RESET_SCHEDULE);
return;
}
var mobileRouteCodeFound = false;
// if early bird fee is in supporting items then need to check the timeslot to see if offer premium is also still available
if (
order.lineItem?.supportingItems?.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE
)
) {
newTimeSlotsResponse.data.days?.forEach((day) => {
day.timeSlots.forEach((ts) => {
if (ts.id === order.schedule.routeCode && ts.offerPremium) {
mobileRouteCodeFound = true;
}
});
});
} else {
newTimeSlotsResponse.data.days?.forEach((day) => {
day.timeSlots.forEach((ts) => {
if (ts.id === order.schedule.routeCode) {
mobileRouteCodeFound = true;
}
});
});
}
if (!mobileRouteCodeFound) {
context.commit(storeMutations.RESET_SCHEDULE);
return;
}
} else { } else {
newTimeSlotsResponse = await context.dispatch( newTimeSlotsResponse = await context.dispatch(
storeActions.GET_SHOP_TIME_SLOTS, storeActions.GET_SHOP_TIME_SLOTS,
@ -2081,24 +2131,24 @@ async function validateAppointment(context, order) {
}, },
false false
); );
}
if (newTimeSlotsResponse?.data.days?.length === 0) { if (newTimeSlotsResponse?.data.days?.length === 0) {
context.commit(storeMutations.RESET_SCHEDULE); context.commit(storeMutations.RESET_SCHEDULE);
return; return;
} }
var routeCodeFound = false; var routeCodeFound = false;
newTimeSlotsResponse.data.days?.forEach((day) => { newTimeSlotsResponse.data.days?.forEach((day) => {
day.timeSlots.forEach((ts) => { day.timeSlots.forEach((ts) => {
if (ts.id === order.schedule.routeCode) { if (ts.id === order.schedule.routeCode) {
routeCodeFound = true; routeCodeFound = true;
} }
});
}); });
});
if (!routeCodeFound) { if (!routeCodeFound) {
context.commit(storeMutations.RESET_SCHEDULE); context.commit(storeMutations.RESET_SCHEDULE);
return; return;
}
} }
} }