lp lookup and start of address lookup

This commit is contained in:
FrankRua 2022-06-29 17:52:02 -04:00
parent 3226ec4e6e
commit ec05b56e51
10 changed files with 282 additions and 292 deletions

View file

@ -3,10 +3,8 @@ 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
@ -54,21 +52,6 @@ export async function navigateToHeritageFunnel() {
);
}
export async function navigateAfterSaveToHeritageFunnel(currentRoute) {
const currentComponent = currentRoute.matched[0].components;
// Create the order (or save existing order) when navigating to Heritage Funnel.
await saveOrder();
router.navigateToExternalUrl(
externalUrls.HERITAGE_FUNNEL,
{
corid: store.getters.order.referralCorrelationId,
src: "concept-funnel"
}
);
}
/*
Logic for getting the last "valid" page a user visited.
*/

View file

@ -8,7 +8,7 @@ import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
import store from "@/store";
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
jest.mock("@/helpers/damage-helper", () => ({
@ -17,7 +17,7 @@ jest.mock("@/helpers/damage-helper", () => ({
}));
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
navigateAfterSaveToHeritageFunnel: jest.fn()
navigateToHeritageFunnel: jest.fn()
}));
describe("address-lookup.vue", () => {
@ -262,7 +262,7 @@ describe("address-lookup.vue", () => {
// Assert
expect(wrapper.vm.updateVehicleInfo).toHaveBeenCalled();
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
expect(navigateToHeritageFunnel).toHaveBeenCalled();
});
test("if the car entered does not match any of the multiple vehicles found, navigate to address-vehicles page", async () => {

View file

@ -132,17 +132,13 @@ export default {
isSelectedGlassAvailableForVehicle: false,
customAlertData: {},
showServiceZipField: this.getServiceZipFromStore(),
isZipServicable: false,
isZipServiceable: false,
}
},
methods: {
arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null;
},
resetDependentState() {
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, null);
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
},
backButtonAction() {
// route to move backwards
this.$router.navigate(
@ -187,50 +183,69 @@ export default {
async forwardButtonAction() {
this.resetWarningsAndErrors();
// Lookup VIN(s) with the provided address
const vinLookupPromise = this.lookupVin(
this.customerQuestions.lastName,
this.customerQuestions.addressQuestions.streetAddress,
this.customerQuestions.addressQuestions.zipCode,
this.customerQuestions.addressQuestions.state
);
let vehicleInfoToCommit = {};
let registrationInfoToCommit = {};
const vinLookupResponse = this.dispatchStoreAction(
storeActions.LOOKUP_VIN_BY_ADDRESS,
{
licenseLastName: this.customerQuestions.lastName,
licenseStreetAddress: this.customerQuestions.addressQuestions.streetAddress,
licenseZip: this.customerQuestions.addressQuestions.zipCode,
licenseState: this.customerQuestions.addressQuestions.state
}, false);
// Settle promises and get results
const promiseResultMap = [
{
resultKey: "vinLookupResponse",
promise: vinLookupResponse
},
{
resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode ?
this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode }) :
this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.customerQuestions.addressQuestions.zipCode })
}
];
const resultMap = await settleAllPromises(promiseResultMap);
// Verify if the service zip code or registration zip code provided is serviceable
const serviceZipValidationPromise = this.serviceZipCode ? this.validateZip(this.serviceZipCode) : this.validateZip(this.customerQuestions.addressQuestions.zipCode);
const vinLookupResponse = await vinLookupPromise;
const serviceZipValidationResponse = await serviceZipValidationPromise;
if (!vinLookupResponse.data.isStatePermissible) {
if (!resultMap.vinLookupResponse.isStatePermissible) {
// State Restrictions forbid lookup by address
this.displayVinLookupByHomeAddressNotAllowedAlert = true;
this.$refs.funnelFooter.removeLoader();
return;
return this.$refs.funnelFooter.removeLoader();
}
// if the neither the registration zip code or service zip code are not serviceable
this.isZipServicable = serviceZipValidationResponse.data.isServiceable;
if (!this.isZipServicable) {
this.isZipServiceable = resultMap.serviceZipValidationResponse.isServiceable;
if (!this.isZipServiceable) {
this.displayNonServiceableZipAlert = true;
this.showServiceZipField = true;
this.$refs.funnelFooter.removeLoader();
} else if (!this.serviceZipCode) {
// if the registration zip code is servicable and nothing was entered for the service zip code
// then set the service zip code to the registration zip code
return this.$refs.funnelFooter.removeLoader();
}
// if the registration zip code is serviceable and nothing was entered for the service zip code
// then set the service zip code to the registration zip code
if (!this.serviceZipCode) {
this.serviceZipCode = this.customerQuestions.addressQuestions.zipCode;
}
const carEntered = store.getters.vehicle;
const carsFound = vinLookupResponse.data.vinVehicles;
//const carEntered = store.getters.vehicle;
const vinsFound = resultMap.vinLookupResponse.vinVehicles;
if (carsFound.length == 0) {
// No VINs found
// No VINs found
if (vinsFound.length == 0) {
this.displayVinNotFoundAlert = true;
this.$refs.funnelFooter.removeLoader();
return;
} else if (carsFound.length == 1) {
const carFound = carsFound[0].vehicle;
this.isCarIdDifferent = carFound.carId !== carEntered.carId;
return this.$refs.funnelFooter.removeLoader();
}
// Single VIN found
if (vinsFound.length == 1) {
const carFound = vinsFound[0].vehicle;
this.isCarIdDifferent = carFound.carId !== this.$store.getters.vehicle.carId;
if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) {
// Display Alert
@ -242,49 +257,93 @@ export default {
// Update button "Continue with..."
this.$refs.funnelFooter.updateButtonText(`Continue with ${carFound.year} ${carFound.make} ${carFound.model}`);
this.$refs.funnelFooter.removeLoader();
return this.$refs.funnelFooter.removeLoader();
}
if (!this.isZipServiceable) {
return;
}
if (!this.isZipServicable) {
return;
}
// update data if the zip or service zip is serviceable
// update data if the zip or service zip is servicable
this.updateVehicleInfo(carsFound[0].vin, carFound);
this.updateCustomerInfo(serviceZipValidationResponse.data.state);
// --> New Save Method
} else if (carsFound.length > 1) {
if (!this.isZipServicable) {
// state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
// state.order.vehicle.registration.address = registrationInfo?.address;
// state.order.vehicle.registration.city = registrationInfo?.city;
// state.order.vehicle.registration.state = registrationInfo?.state;
// state.order.vehicle.registration.zipCode = registrationInfo?.zipCode;
// state.order.vehicle.registration.firstName = registrationInfo?.firstName;
// state.order.vehicle.registration.lastName = registrationInfo?.lastName;
vehicleInfoToCommit = Object.assign(carFound, { vin: vinsFound[0].vin});
registrationInfoToCommit = {
firstName: this.customerQuestions.firstName,
lastName: this.customerQuestions.lastName,
address: this.customerQuestions.addressQuestions.streetAddress,
city: this.customerQuestions.addressQuestions.city,
state: this.customerQuestions.addressQuestions.state,
zipCode: this.customerQuestions.addressQuestions.zipCode
};
this.updateVehicleInfo(vinsFound[0].vin, carFound);
this.updateCustomerInfo(resultMap.serviceZipValidationResponse.state);
}
// Found more than one VIN.
if (vinsFound.length > 1) {
if (!this.isZipServiceable) {
return;
}
// if multiple cars were found
let matchingCars = carsFound.filter(car => car.vehicle.carId === carEntered.carId);
const matchingCars = vinsFound.filter(vin => vin.vehicle.carId === this.$store.getters.vehicle.carId);
// and one and only one of them matches the carId entered, save the vehicle info
// so we can go to the Heritage Funnel directly
if (matchingCars.length === 1) {
// and one and only one of them matches the carId entered, save the vehicle info
// so we can go to the Heritage Funnel directly
const matchingCar = matchingCars[0];
this.updateVehicleInfo(matchingCar.vin, matchingCar.vehicle);
this.updateVehicleInfo(matchingCars[0].vin, matchingCars[0].vehicle);
}
// update data if the zip or service zip is servicable
this.updateCustomerInfo(serviceZipValidationResponse.data.state);
// update data if the zip or service zip is serviceable.
this.updateCustomerInfo(resultMap.serviceZipValidationResponse.state);
}
this.navigateForward(carEntered, carsFound);
// store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, this.customerQuestions.addressQuestions.streetAddress);
// store.commit(storeMutations.UPDATE_REGISTRATION_CITY, this.customerQuestions.addressQuestions.city);
// store.commit(storeMutations.UPDATE_REGISTRATION_STATE, this.customerQuestions.addressQuestions.state);
// store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.customerQuestions.addressQuestions.zipCode);
// store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, this.customerQuestions.firstName);
// store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, this.customerQuestions.lastName);
// store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZipCode);
// store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, serviceState);
// store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.customerQuestions.emailAddress);
// Save vin, vehicle, customer, service and registration information
await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP, {
isCarIdDifferent: this.isCarIdDifferent,
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin }),
serviceLocationInfo: {
zipCode: this.serviceZip,
state: resultMap.serviceZipValidationResponse.state,
},
registrationInfo: {
licensePlate: this.licensePlate,
state: resultMap.registrationZipValidationResponse.state,
zipCode: this.registrationZip,
},
customerEmail: this.email,
}, false);
return await this.navigateForward(carEntered, vinsFound);
},
resetWarningsAndErrors() {
this.displayVinNotFoundAlert = false;
this.displayNonServiceableZipAlert = false;
this.displayMatchedDifferentVehicleAlert = false;
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
},
navigateForward(carEntered, carsFound) {
async navigateForward(carEntered, vinsFound) {
this.updateServiceLocationIfNecessary();
if (carsFound.length == 1) {
if (vinsFound.length == 1) {
// if a different vehicle is found than the one entered and the selected glass
// is not available for that vehicle
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
@ -298,11 +357,11 @@ export default {
);
} else {
// otherwise
this.navigateForwardWithSingleCarMatch();
await this.navigateForwardWithSingleCarMatch();
}
} else if (carsFound.length > 1) {
} else if (vinsFound.length > 1) {
// if multiple cars were found
let matchingCars = carsFound.filter(car => car.vehicle.carId === carEntered.carId);
let matchingCars = vinsFound.filter(car => car.vehicle.carId === carEntered.carId);
if (matchingCars.length === 1) {
// and one and only of them matches the car id entered
const matchingCar = matchingCars[0];
@ -310,39 +369,18 @@ export default {
this.navigateForwardWithSingleCarMatch();
} else {
// if there are no matches or there are multiple matches, navigate to "address-vehicles" page
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound);
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, vinsFound);
}
}
},
validateZip(zip) {
return this.dispatchStoreAction(
storeActions.VALIDATE_ZIP,
{ zip });
},
lookupVin(lastName, streetAddress, zip, state) {
return this.dispatchStoreAction(
storeActions.LOOKUP_VIN_BY_ADDRESS,
{
licenseLastName: lastName,
licenseStreetAddress: streetAddress,
licenseZip: zip,
licenseState: state
}, false
);
},
updateVehicleInfo(vin, vehicleInfo) {
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
store.commit(storeMutations.UPDATE_MAKE, vehicleInfo.make);
store.commit(storeMutations.UPDATE_MODEL, vehicleInfo.model);
store.commit(storeMutations.UPDATE_STYLE, vehicleInfo.style);
store.commit(storeMutations.UPDATE_CAR_ID, vehicleInfo.carId);
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, vehicleInfo.category);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, vehicleInfo.imageUrl);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, vehicleInfo.imageVifNumber);
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, vehicleInfo.imageColor);
resetWarningsAndErrors() {
this.displayVinNotFoundAlert = false;
this.displayNonServiceableZipAlert = false;
this.displayMatchedDifferentVehicleAlert = false;
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
},
updateCustomerInfo(serviceState) {
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, this.customerQuestions.addressQuestions.streetAddress);
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, this.customerQuestions.addressQuestions.city);

View file

@ -230,7 +230,7 @@ describe("addressVehicles.vue", () => {
const { wrapper } = setupMocks({});
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
// Act
await wrapper.setData({

View file

@ -246,7 +246,7 @@ describe("license-plate-lookup.vue", () => {
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
});
test("navigateAfterSaveToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
test("navigateToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
// Arrange
const { wrapper } = setupMocks({});
@ -258,11 +258,11 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
return '';
});
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
await wrapper.vm.navigateForward();
//Assert
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
expect(navigateToHeritage.navigateToHeritageFunnel).toHaveBeenCalled();
});
test("carId matches returned vehicle => navigateForwardWithSingleCarMatch", async () => {
@ -366,7 +366,7 @@ describe("license-plate-lookup.vue", () => {
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => new Promise(resolve => resolve(vinLookup)));
await wrapper.setData({ registrationZip: "00000" });
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
// Act
await wrapper.vm.forwardButtonAction();
@ -385,7 +385,7 @@ describe("license-plate-lookup.vue", () => {
});
await wrapper.setData({ registrationZip: "00000" });
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
// Act
await wrapper.vm.forwardButtonAction();
@ -404,7 +404,7 @@ describe("license-plate-lookup.vue", () => {
});
await wrapper.setData({ registrationZip: "00000" });
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
await wrapper.vm.forwardButtonAction();
wrapper.vm.$router.navigateAfterSave = jest.fn();
// At this point, serviceZip field is shown
@ -417,7 +417,7 @@ describe("license-plate-lookup.vue", () => {
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
expect(serviceZipField.exists()).toBe(true);
expect(serviceZipField.isVisible()).toBe(true); 3
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).not.toHaveBeenCalled();
expect(navigateToHeritage.navigateToHeritageFunnel).not.toHaveBeenCalled();
expect(wrapper.vm.$router.navigateAfterSave).not.toHaveBeenCalled();
});

View file

@ -50,13 +50,13 @@
class="my-3"
:manualHeadline="NoServiceZipHeader"
:manualCopy="NoServiceZipBody"
v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent"
v-if="!isRegistrationZipServiceable && isVinValid && !isCarIdDifferent"
alertClass="alert-danger"
/>
<div class="row my-2">
<div class="col">
<textboxQuestion
v-if="!isRegistrationZipServicable"
v-if="!isRegistrationZipServiceable"
cmsWidgetName="ServiceZip"
v-model="serviceZip"
inputId="serviceZip"
@ -98,17 +98,15 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
import alert from "@/ux-components/alert/alert";
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations";
import { errorMessages } from "@/constants/error-messages";
import {
getDamageString,
isGlassAvailableForCarId,
} from "@/helpers/damage-helper";
import { getDamageString,isGlassAvailableForCarId} from "@/helpers/damage-helper";
import { routerParams } from "@/router/router-constants/router-params";
import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -160,7 +158,7 @@ export default {
},
data() {
return {
isRegistrationZipServicable: true,
isRegistrationZipServiceable: true,
isVinValid: true,
isCarIdDifferent: false,
licensePlate: this.getLicensePlateFromStore(),
@ -178,38 +176,20 @@ export default {
},
computed: {
MatchedDifferentVehicleAlertHeader() {
let text = this.getCmsContent(
"MatchedDifferentVehicleAlertWidget",
"HeadlineText"
).replaceAll("{custom:damage}", getDamageString());
return text;
return this.getCmsContent("MatchedDifferentVehicleAlertWidget","HeadlineText")
.replaceAll("{custom:damage}", getDamageString());
},
MatchedDifferentVehicleAlertBody() {
let text = this.getCmsContent(
"MatchedDifferentVehicleAlertWidget",
"BodyText"
)
return this.getCmsContent("MatchedDifferentVehicleAlertWidget","BodyText")
.replaceAll("{custom:damage}", getDamageString())
.replaceAll(
"{custom:plateLookupYear}",
this.customAlertData?.vehicleInfo?.year
)
.replaceAll(
"{custom:plateLookupMake}",
this.customAlertData?.vehicleInfo?.make
)
.replaceAll(
"{custom:plateLookupModel}",
this.customAlertData?.vehicleInfo?.model
);
return text;
.replaceAll("{custom:plateLookupYear}",this.customAlertData?.vehicleInfo?.year)
.replaceAll("{custom:plateLookupMake}",this.customAlertData?.vehicleInfo?.make)
.replaceAll("{custom:plateLookupModel}",this.customAlertData?.vehicleInfo?.model);
},
NoServiceZipHeader() {
let text = this.getCmsContent(
"NoServiceZipWidget",
"HeadlineText"
).replaceAll("{custom:zip}", this.zipToDisplay);
return text;
return this.getCmsContent("NoServiceZipWidget","HeadlineText")
.replaceAll("{custom:zip}", this.zipToDisplay);
},
NoServiceZipBody() {
return this.getCmsContent("NoServiceZipWidget", "BodyText");
@ -230,110 +210,100 @@ export default {
});
},
getLicensePlateFromStore() {
return store.getters.vehicle.registration.licensePlate;
return this.$store.getters.vehicle.registration.licensePlate;
},
getRegistrationZipFromStore() {
return store.getters.vehicle.registration.zipCode;
return this.$store.getters.vehicle.registration.zipCode;
},
getEmailFromStore() {
return store.getters.order.customer.emailAddress;
return this.$store.getters.order.customer.emailAddress;
},
getServiceZipFromStore() {
return store.getters.order.serviceLocation.zipCode;
return this.$store.getters.order.serviceLocation.zipCode;
},
backButtonAction() {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
async forwardButtonAction() {
//Call zip validation services
const registrationZipValidationPromise = this.validateZip(this.registrationZip);
const registrationZipValidationResults = await registrationZipValidationPromise;
const registrationZipValidationResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.registrationZip });
const serviceZipValidationPromise = this.serviceZip? this.validateZip(this.serviceZip): null;
const serviceZipValidationResults = serviceZipValidationPromise !== null ? await serviceZipValidationPromise: registrationZipValidationResults;
// Settle promises and get results
const promiseResultMap = [
{
resultKey: "registrationZipValidationResponse",
promise: registrationZipValidationResponse,
},
{
resultKey: "serviceZipValidationResponse",
promise: this.serviceZip ? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZip }) : registrationZipValidationResponse,
}
];
const resultMap = await settleAllPromises(promiseResultMap);
//Handle service zip validations
if (!serviceZipValidationResults.data.isServiceable) {
this.$refs.funnelFooter.removeLoader();
if (!resultMap.serviceZipValidationResponse.isServiceable) {
this.isVinValid = true;
this.isRegistrationZipServicable = false;
this.isRegistrationZipServiceable = false;
this.isCarIdDifferent = false;
this.zipToDisplay = this.serviceZip
? this.serviceZip
: this.registrationZip;
return;
} else if (!this.serviceZip) {
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip;
return this.$refs.funnelFooter.removeLoader();
}
if (!this.serviceZip) {
this.serviceZip = this.registrationZip;
}
//Lookup vin
const vinLookup = await this.lookupVin(
this.licensePlate,
registrationZipValidationResults.data.state
).catch(() => {
this.$refs.funnelFooter.removeLoader();
const vinLookup = await this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,
{ licensePlate: this.licensePlate, licenseState: resultMap.registrationZipValidationResponse.state }, false)
.catch(() => {
this.isVinValid = false;
this.isCarIdDifferent = false;
return;
return this.$refs.funnelFooter.removeLoader();
});
this.isCarIdDifferent =
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
// Check if the CarId has changed.
this.isCarIdDifferent = vinLookup.data.vehicle.carId !== this.$store.getters.vehicle.carId;
//Handle changing car
if (
this.isCarIdDifferent &&
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
) {
if (this.isCarIdDifferent && vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId) {
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
this.$refs.funnelFooter.updateButtonText(`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`);
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
this.$refs.funnelFooter.updateButtonText(
`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`
);
this.isVinValid = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
this.$refs.funnelFooter.removeLoader();
return;
return this.$refs.funnelFooter.removeLoader();
}
// Save vin and vehicle information
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
// Save vin, vehicle, customer, service and registration information
await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP, {
isCarIdDifferent: this.isCarIdDifferent,
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin})
});
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin }),
serviceLocationInfo: {
zipCode: this.serviceZip,
state: resultMap.serviceZipValidationResponse.state,
},
registrationInfo: {
licensePlate: this.licensePlate,
state: resultMap.registrationZipValidationResponse.state,
zipCode: this.registrationZip,
},
customerEmail: this.email,
}, false);
//Navigate
this.navigateForward();
return await this.navigateForward();
},
navigateForward() {
async navigateForward() {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route,
{},
{ displayVehicleChangeAlert: true },
{}
);
return;
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,this.$route,{}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
} else {
this.navigateForwardWithSingleCarMatch();
return;
await this.navigateForwardWithSingleCarMatch();
}
},
validateZip(zip) {
return this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
zip,
});
},
lookupVin(plate, state) {
return this.dispatchStoreAction(
storeActions.LOOKUP_VIN_BY_PLATE,
{ licensePlate: plate, licenseState: state },
false
);
},
},
watch: {
licensePlate() {

View file

@ -124,7 +124,6 @@ import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
// Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import store from "@/store";
import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations";
import { errorMessages } from "@/constants/error-messages";
@ -133,6 +132,8 @@ import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate";
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import { routerParams } from "@/router/router-constants/router-params";
import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
// DEFINE VALIDATION RULES
@ -243,13 +244,13 @@ export default {
return store.getters.vehicle.carId !== null;
},
getEmailFromStore(){
return store.getters.order.customer.emailAddress;
return this.$store.getters.order.customer.emailAddress;
},
getVinFromStore(){
return store.getters.vehicle.vin;
return this.$store.getters.vehicle.vin;
},
getZipFromStore(){
return store.getters.order.serviceLocation.zipCode;
return this.$store.getters.order.serviceLocation.zipCode;
},
attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => {
@ -267,7 +268,7 @@ export default {
}
},
backButtonAction() {
if (store.getters.vehicle.vin) {
if (this.$store.getters.vehicle.vin) {
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route);
}
else {
@ -327,7 +328,7 @@ export default {
}
// Save vin, vehicle, customer and service information
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
await this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
isCarIdDifferent: this.isCarIdDifferent,
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }),
@ -338,7 +339,7 @@ export default {
customerEmail: this.email,
}, false);
this.navigateForward();
return await this.navigateForward();
}
// If a VIN has already been found. Validate the Service Zip (in case of changes)
@ -348,14 +349,14 @@ export default {
if (zipValidationResponse.data.isServiceable) {
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
this.$store.commit(storeActions.UPDATE_SERVICE_LOCATION, {
await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, {
zipCode: this.zip,
state: zipValidationResponse.data.state
});
}, false);
this.$store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
this.navigateForward();
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.email, false);
return await this.navigateForward();
}
// If the Service Zip is NOT serviceable then show an alert
@ -363,11 +364,11 @@ export default {
return this.$refs.funnelFooter.removeLoader();
},
navigateForward(){
async navigateForward(){
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
} else {
this.navigateForwardWithSingleCarMatch();
await this.navigateForwardWithSingleCarMatch();
}
},
setupUiForNonServiceableZip(zip) {

View file

@ -1,7 +1,7 @@
import store from "@/store";
import { storeActions } from "@/constants/store-actions.js";
import { storeMutations } from "@/constants/store-mutations.js";
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
export default {
methods: {
@ -13,15 +13,15 @@ export default {
const hasGlassLocationWithMultipleParts = partsOrQuestions.some(pq => pq.parts?.length > 1);
if (hasPartsQuestions) {
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data);
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data);
}
else if (hasGlassLocationWithMultipleParts) {
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
}
else {
store.commit(storeMutations.UPDATE_GLASS_PARTS, result.data);
this.$refs.loadingModal.showModal();
navigateAfterSaveToHeritageFunnel(this.$route);
navigateToHeritageFunnel();
}
}
}

View file

@ -6,10 +6,10 @@ import { storeMutations } from "@/constants/store-mutations";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
import store from "@/store";
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
navigateAfterSaveToHeritageFunnel: jest.fn()
navigateToHeritageFunnel: jest.fn()
}));
describe("vin-pages-mixin", () => {
@ -771,7 +771,7 @@ describe("vin-pages-mixin", () => {
await wrapper.vm.navigateForwardWithSingleCarMatch();
// Assert
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalledTimes(1);
expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1);
});
test("multiple glass locations selected, each has one part and no part questions => go to heritage funnel", async () => {
@ -864,7 +864,7 @@ describe("vin-pages-mixin", () => {
partsOrQuestions: partsOrQuestions
});
// wrapper.vm.navigateAfterSaveToHeritageFunnel = jest.fn();
// wrapper.vm.navigateToHeritageFunnel = jest.fn();
store.commit = jest.fn();
// Act
@ -874,7 +874,7 @@ describe("vin-pages-mixin", () => {
expect(store.commit).toHaveBeenCalledTimes(1);
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, { partsOrQuestions })
expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1);
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalledTimes(1);
expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1);
});
});
});

View file

@ -653,6 +653,7 @@ export const actions = {
// Business domain actions
// Vehicle domain
saveVehicleYear(context, year) {
//Reset dependent state when changing
@ -750,10 +751,29 @@ export const actions = {
context.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, selectedGlassToReplace);
}
},
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
// Vin domain
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
//Reset dependent state when changing
if (registrationInfo?.licensePlate !== context.state.order.registration?.licensePlate) {
if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
}
//Save new values
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
},
saveRegistrationLicensePlateLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
//Reset dependent state when changing
if (registrationInfo?.licensePlate !== context.state.order.vehicle.registration?.licensePlate) {
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
@ -765,57 +785,35 @@ export const actions = {
//Save new values
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, customerEmail);
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
},
saveRegistrationAddressLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail}) {
//Reset dependent state when changing
if (registrationInfo?.address !== context.state.order.vehicle.registration?.address || registrationInfo?.city !== context.state.order.vehicle.registration?.city || registrationInfo?.state !== context.state.order.vehicle.registration?.state || registrationInfo?.zipCode !== context.state.order.vehicle.registration?.zipCode || registrationInfo?.firstName !== context.state.order.vehicle.registration?.firstName || registrationInfo?.lastName !== context.state.order.vehicle.registration?.lastName) {
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
}
//Save new values
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
},
saveServiceLocation(context, serviceLocationInfo) {
context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo);
},
saveRegistrationLicensePlateLookup(context, { registrationInfo, serviceState, serviceZip, customerEmail, vehicleInfo, isCarIdDifferent, isSelectedGlassAvailableForVehicle }) {
if (registrationInfo.licensePlate !== context.state.order.registration.licensePlate || registrationInfo.zipcode !== context.state.order.registration.zipcode) {
//Reset dependent state when changing
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
//Save new values
context.dispatch(storeActions.SAVE_VIN_LOOKUP, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo });
context.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, registrationInfo.licensePlate);
context.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationInfo.state);
context.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, registrationInfo.zipCode);
context.dispatch(storeActions.SAVE_SERVICE_ZIP, serviceZip);
context.dispatch(storeActions.SAVE_SERVICE_STATE, serviceState);
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
}
},
saveRegistrationAddressLookup(context, { licensePlate }) {
if (context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle) {
storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES;
}
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
},
saveServiceLocation(context, { zipcode, state }) {
if (zipcode !== context.state.order.service.zipcode || state !== context.state.order.service.state) {
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, zipcode);
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, state);
}
},
saveEmail(context, email) {
if (email !== context.state.order.customer.email) {
context.commit(storeMutations.UPDATE_CUSTOM, email);
}
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email);
},
saveVin(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo }) {