diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js
index ed5b6aa85..f2a74a723 100644
--- a/src/constants/error-messages.js
+++ b/src/constants/error-messages.js
@@ -17,6 +17,8 @@ const errorMessages = {
LAST_NAME_REQUIRED: "Please enter your last name",
EMAIL_ADDRESS_REQUIRED: "Please enter your email address",
EMAIL_ADDRESS_FORMAT: "Please enter a valid email address",
+ SERVICE_ZIP_REQUIRED: "Please enter your Service ZIP",
+ SERVICE_ZIP_FORMAT: "Please enter a valid Service ZIP",
};
export { errorMessages };
\ No newline at end of file
diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js
index 640364213..3ce2bd6da 100644
--- a/src/constants/store-actions.js
+++ b/src/constants/store-actions.js
@@ -12,6 +12,7 @@ const storeActions = {
LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms",
LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin",
LOOKUP_VIN_BY_PLATE: "lookupVinByPlate",
+ LOOKUP_VIN_BY_ADDRESS: "lookupVinByAddress",
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
SAVE_ORDER: "saveOrder",
LOAD_ORDER: "loadOrder",
diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue
index 9e3cbb88d..dd98d95da 100644
--- a/src/layouts/address-lookup/address-lookup.vue
+++ b/src/layouts/address-lookup/address-lookup.vue
@@ -10,11 +10,41 @@
+
+
+
+
+
+
+
+
@@ -36,6 +66,9 @@ import store from "@/store";
// import { storeActions } from "@/constants/store-actions";
// import baseMixin from "@/mixins/base-mixin";
+defineRule("service-zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
+defineRule("service-zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT));
+
export default {
name: "address-lookup",
async beforeRouteEnter(to, from, next) {
@@ -77,8 +110,8 @@ export default {
return store.getters.vehicle.carId !== null;
},
resetDependentState() {
- // Invokes
-
+ store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, null);
+ store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
},
backButtonAction() {
// route to move backwards
@@ -87,46 +120,86 @@ export default {
this.$route
);
},
- async forwardButtonAction() {
- store.commit(this.storeMutations.UPDATE_IS_REPAIR, this.isWindshieldRepair);
+ async forwardButtonAction() {
+
+
+ // look-up VIN by address
+ const vinLookup = await this.lookupVin(this.lastName, this.streetAddress, this.zip, this.state);
+
+ if (vinLookup.isStatePermissable) {
+ // State Restrictions allow lookup by address
+ if (vinLookup.vinVehicles.length == 0) {
+ // no VINs found
+ this.$refs.funnelFooter.removeLoader();
+ this.displayVinNotFoundAlert = true;
+ }
+
+ const zipValidation = this.serviceZip ? await this.validateZip(this.serviceZip) : await this.validateZip(this.zip);
+ if (!zipValidation.data.isServiceable) {
+ this.$refs.funnelFooter.removeLoader();
+ this.displayNonServiceableZipAlert = true;
+ return;
+ }
- if (this.isWindshieldRepair){
- store.commit(this.storeMutations.UPDATE_NUMBER_OF_CHIPS, parseInt(this.selectedWindshieldOptions.selectedWindshieldChipCount));
} else {
- store.commit(this.storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
+ // State Restrictions forbid lookup by address
+ this.$refs.funnelFooter.removeLoader();
+ this.displayVinLookupByHomeAddressNotAllowedAlert = true;
+
}
- store.commit(this.storeMutations.UPDATE_GLASS_TO_REPLACE, this.selectedGlassToReplace());
- const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS,
- { carId: store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false);
+ // const vinLookup = await this.lookupVin(this.lastName, this.streetAddress, this.zip, this.state).catch(() => {
+ // this.$refs.funnelFooter.removeLoader();
+ // this.vinNotValid = true;
+ // return;
+ // });
- this.navigateForward(partsData);
- },
- navigateForward(partsData) {
- // found parts questions
- if (partsData.data.partsOrQuestions.some(pq => pq.partQuestions != null && pq.partQuestions.length > 0)){
- this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_PART_QUESTIONS, this.$route, {}, {}, partsData.data);
+ if (vinLookup.data.vehicle.carId !== store.getters.vehicle.carId) {
+ this.$refs.funnelFooter.updateButtonText(`Continue with ${vinLookup.data.vin} ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`);
+ this.$refs.funnelFooter.removeLoader();
+ this.vinDoesNotMatchCarId = true;
return;
}
- // found multiple parts for a single glass location (Windshield, Driver, Passenger, Rear)
- if (partsData.data.partsOrQuestions){
- for (var i = 0; i < partsData.data.partsOrQuestions.length; i++){
- if (partsData.data.partsOrQuestions[i].parts != null && partsData.data.partsOrQuestions[i].parts.length > 1){
- this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_MULTIPLE_PARTS, this.$route, {}, {}, partsData.data);
- return;
- }
- }
- }
-
- //if not a repair then there should only be 1 part and no problem questions at this point so save the part to the store.
- if (!this.isWindshieldRepair){
- store.commit(this.storeMutations.UPDATE_PARTS, partsData.data.partsOrQuestions[0].parts);
- }
-
- this.$router.navigate(this.navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, this.$route);
+ const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(
+ this.storeActions.GET_PARTS_OR_QUESTIONS,
+ {
+ carId: store.getters.vehicle.carId,
+ glassArray: store.getters.damage.glassToReplace,
+ zipCode: this.zip,
+ vin: vinLookup.vin
+ }, false
+ );
+ this.navigateForward(partsData);
},
+ navigateForward(partsData){
+ if(partsData.data.partsOrQuestions[0].partQuestions && partsData.data.partsOrQuestions[0].partQuestions.length > 0){
+ this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_PARTS_QUESTION, this.$route, {}, {}, partsData.data);
+ return;
+ } else if((!partsData.data.partsOrQuestions[0].partQuestions || partsData.data.partsOrQuestions[0].partQuestions.length < 1) && partsData.data.partsOrQuestions[0].parts.length > 1) {
+ this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_PARTS, this.$route, {}, {}, partsData.data);
+ return;
+ } else {
+ this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_SINGLE_PART, this.$route);
+ }
+ },
+ validateZip(zip) {
+ return baseMixin.methods.dispatchNonBlockingStoreAction(
+ storeActions.VALIDATE_ZIP,
+ { zip });
+ },
+ lookupVin(lastName, streetAddress, zip, state) {
+ return baseMixin.methods.dispatchNonBlockingStoreAction(
+ storeActions.LOOKUP_VIN_BY_ADDRESS,
+ {
+ licenseLastName: lastName,
+ licenseStreetAddress: streetAddress,
+ licenseZip: zip,
+ licenseState: state
+ }
+ );
+ },
},
components: {
funnelHeader,