Revert "Revert "Feature/csr 416""
This commit is contained in:
parent
fd4de9386e
commit
764c8559d2
8 changed files with 106 additions and 26 deletions
|
|
@ -22,6 +22,7 @@ const storeActions = {
|
|||
LOG_PAGE_VIEW: "logPageView",
|
||||
LOG_CUSTOM_EVENT: "logCustomEvent",
|
||||
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
|
||||
UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ const storeMutations = {
|
|||
|
||||
// OTHER MUTATIONS
|
||||
UPDATE_PAGE_DATA: "updatePageData",
|
||||
UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation"
|
||||
|
||||
UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation",
|
||||
UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration"
|
||||
};
|
||||
|
||||
export { storeMutations };
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
|||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import store from "@/store";
|
||||
import router from "@/router";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
|
||||
/*
|
||||
If the user has visited the funnel before this method will determine the bets place to
|
||||
|
|
@ -12,7 +14,6 @@ import router from "@/router";
|
|||
the user has an existing order and they come back in from the Safelite.com CTA.
|
||||
*/
|
||||
export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHeritageOrder = false) {
|
||||
|
||||
// If the user is coming in via the Safelite.Com CTA
|
||||
if (toRoute.query[queryStrings.START_TYPE] === 'fmg') {
|
||||
// If they have an existing order, return 'heritage' for the page name.
|
||||
|
|
@ -56,6 +57,9 @@ export async function navigateToHeritageFunnel() {
|
|||
export async function navigateAfterSaveToHeritageFunnel(currentRoute) {
|
||||
const currentComponent = currentRoute.matched[0].components;
|
||||
currentComponent.default.methods.resetDependentState();
|
||||
|
||||
setupOrderBeforeSave();
|
||||
|
||||
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
||||
await saveOrder();
|
||||
|
||||
|
|
@ -140,4 +144,14 @@ function isVinRelatedPage(toRoute) {
|
|||
fmgPageValue === fmgPageValues.ADDRESS_LOOKUP ||
|
||||
fmgPageValue === fmgPageValues.ADDRESS_VEHICLES ||
|
||||
fmgPageValue === fmgPageValues.ESTIMATE;
|
||||
}
|
||||
|
||||
function setupOrderBeforeSave() {
|
||||
const serviceLocation = store.getters.order.serviceLocation;
|
||||
|
||||
if (!serviceLocation.zipCode && serviceLocation.zipCode == store.getters.vehicle.registration.zipCode) {
|
||||
baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -87,8 +87,6 @@ import { required } from "@/helpers/validation-rules";
|
|||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
||||
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
|
||||
import store from "@/store";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ export default {
|
|||
return store.getters.vehicle.vin
|
||||
},
|
||||
getZipFromStore(){
|
||||
return store.getters.vehicle.registration.zipCode
|
||||
return store.getters.order.serviceLocation.zipCode;
|
||||
},
|
||||
attachCustomEvents() {
|
||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||
|
|
@ -281,7 +281,12 @@ export default {
|
|||
});
|
||||
},
|
||||
backButtonAction() {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
if (store.getters.vehicle.vin) {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route);
|
||||
}
|
||||
else {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
}
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const zipValidation = this.validateZip(this.zip);
|
||||
|
|
|
|||
|
|
@ -107,6 +107,10 @@ const routingTable = [
|
|||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN,
|
||||
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
|
||||
}
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const getDefaultState = () => {
|
|||
model: null,
|
||||
style: null,
|
||||
carId: null,
|
||||
category: null,
|
||||
category: null,
|
||||
vin: null,
|
||||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
|
|
@ -31,6 +31,9 @@ const getDefaultState = () => {
|
|||
},
|
||||
},
|
||||
serviceLocation: {
|
||||
address: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
},
|
||||
customer: {
|
||||
|
|
@ -227,18 +230,39 @@ export const mutations = {
|
|||
imageUrl: orderInformation.vehicle?.imageUrl,
|
||||
imageVifNumber: orderInformation.vehicle?.imageVifNumber,
|
||||
imageColor: orderInformation.vehicle?.imageVifColor,
|
||||
registration: {
|
||||
firstName: orderInformation.vehicle.registration.firstName,
|
||||
lastName: orderInformation.vehicle.registration.lastName,
|
||||
address: orderInformation.vehicle.registration.streetAddress,
|
||||
city: orderInformation.vehicle.registration.city,
|
||||
state: orderInformation.vehicle.registration.state,
|
||||
zipCode: orderInformation.vehicle.registration.zipCode,
|
||||
licensePlate: orderInformation.vehicle.registration.licensePlate,
|
||||
}
|
||||
});
|
||||
|
||||
state.order.damage.glassToReplace = orderInformation.glassToReplace;
|
||||
state.order.damage.isRepair = orderInformation.isRepair;
|
||||
state.order.damage.numberOfChips = orderInformation.numberOfChips;
|
||||
state.order.damage.glassToReplace = orderInformation.damage.glassToReplace;
|
||||
state.order.damage.isRepair = orderInformation.damage.isRepair;
|
||||
state.order.damage.numberOfChips = orderInformation.damage.numberOfChips;
|
||||
|
||||
state.order.lineItems.glassParts = orderInformation.parts;
|
||||
state.order.accountNumber = orderInformation.accountNumber;
|
||||
state.order.serviceLocation.zipCode = orderInformation.zipCode;
|
||||
state.order.serviceLocation.address = orderInformation.serviceLocation.streetAddress,
|
||||
state.order.serviceLocation.city = orderInformation.serviceLocation.city,
|
||||
state.order.serviceLocation.state = orderInformation.serviceLocation.state,
|
||||
state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode;
|
||||
|
||||
state.order.payment.isInsurance = orderInformation.IsInsuranceOrder;
|
||||
state.order.payment.insuranceCoverage.isVerified = orderInformation?.insuranceInfo.coverageVerified;
|
||||
|
||||
state.order.customer.emailAddress = orderInformation.customer.emailAddress;
|
||||
},
|
||||
|
||||
updateServiceLocationWithVehicleRegistration(state) {
|
||||
state.order.serviceLocation.address = state.order.vehicle.registration.address;
|
||||
state.order.serviceLocation.city = state.order.vehicle.registration.city;
|
||||
state.order.serviceLocation.state = state.order.vehicle.registration.state;
|
||||
state.order.serviceLocation.zipCode = state.order.vehicle.registration.zipCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,6 +443,9 @@ export const actions = {
|
|||
context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId);
|
||||
},
|
||||
updateServiceLocationWithVehicleRegistration(context) {
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
||||
},
|
||||
|
||||
logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) {
|
||||
return globalMethods.callHttpClient({
|
||||
|
|
@ -502,6 +529,7 @@ export const actions = {
|
|||
saveOrder(context) {
|
||||
const vehicle = context.getters.vehicle;
|
||||
const damage = context.getters.damage;
|
||||
const order = context.state.order;
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.SaveOrder.method,
|
||||
|
|
@ -513,14 +541,34 @@ export const actions = {
|
|||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
vin: vehicle.vin
|
||||
vin: vehicle.vin,
|
||||
registration: {
|
||||
firstName: vehicle.registration.firstName,
|
||||
lastName: vehicle.registration.lastName,
|
||||
streetAddress: vehicle.registration.address,
|
||||
city: vehicle.registration.city,
|
||||
state: vehicle.registration.state,
|
||||
zipCode: vehicle.registration.zipCode,
|
||||
licensePlateNumber: vehicle.registration.licensePlate,
|
||||
},
|
||||
},
|
||||
numberOfChips: damage.numberOfChips,
|
||||
zipCode: 43215, // TODO CSR-416, should not be hardcoded (state.order.serviceLocation.zipCode)
|
||||
glassToReplace: damage.glassToReplace,
|
||||
referralNumber: context.state.order.referralNumber,
|
||||
referralDate: context.state.order.referralDate,
|
||||
accountNumber: context.state.order.accountNumber
|
||||
damage: {
|
||||
numberOfChips: damage.numberOfChips,
|
||||
glassToReplace: damage.glassToReplace,
|
||||
isRepair: damage.isRepair
|
||||
},
|
||||
customer: {
|
||||
emailAddress: order.customer.emailAddress,
|
||||
},
|
||||
serviceLocation: {
|
||||
streetAddress: order.serviceLocation.address,
|
||||
city: order.serviceLocation.city,
|
||||
state: order.serviceLocation.state,
|
||||
zipCode: order.serviceLocation.zipCode
|
||||
},
|
||||
referralNumber: order.referralNumber,
|
||||
referralDate: order.referralDate,
|
||||
accountNumber: order.accountNumber
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -215,14 +215,19 @@ describe("Mutations", () => {
|
|||
model: "ILX",
|
||||
style: "4 DOOR SEDAN",
|
||||
carId: "C0000001",
|
||||
category: "CAR"
|
||||
category: "CAR",
|
||||
registration: {}
|
||||
},
|
||||
damage: {
|
||||
glassToReplace: ["Windshield"],
|
||||
isRepair: false,
|
||||
numberOfChips: 0,
|
||||
},
|
||||
glassToReplace: ["Windshield"],
|
||||
isRepair: false,
|
||||
numberOfChips: 0,
|
||||
parts: [],
|
||||
accountNumber: "123456789",
|
||||
insuranceInfo: {}
|
||||
insuranceInfo: {},
|
||||
serviceLocation: {},
|
||||
customer: {}
|
||||
});
|
||||
|
||||
// Assert
|
||||
|
|
@ -562,11 +567,16 @@ describe("Actions", () => {
|
|||
const context = state;
|
||||
|
||||
context.getters = {
|
||||
vehicle: {},
|
||||
vehicle: {
|
||||
registration: {}
|
||||
},
|
||||
damage: {},
|
||||
};
|
||||
context.state = {
|
||||
order: {}
|
||||
order: {
|
||||
serviceLocation: {},
|
||||
customer: {}
|
||||
}
|
||||
};
|
||||
|
||||
globalMethods.callHttpClient.mockImplementation(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue