From 30f826faff3ca672c95ddf77ccb99e70943e05b2 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 8 Jun 2022 12:25:50 -0400 Subject: [PATCH] CSR-466 Update vin-lookup navigation --- src/layouts/address-lookup/address-lookup.vue | 4 +-- src/layouts/part-questions/part-questions.vue | 2 ++ src/layouts/vin-lookup/vin-lookup.vue | 36 ++++++++++++++----- .../router-constants/navigation-scenarios.js | 4 +-- src/router/router-constants/routing-table.js | 10 +++++- src/store/index.js | 12 ++++++- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 8e58d09b0..f29e3d21a 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -329,8 +329,8 @@ export default { { licenseLastName: lastName, licenseStreetAddress: streetAddress, - licenseZip: zip, - licenseState: state, + licenseZip: zip, + licenseState: state }, false ); }, diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index e8c021954..54c4aaf4d 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -66,8 +66,10 @@ export default { }, arePagePrerequisitesValid() { if (Object.keys(store.getters.pageData(fmgPageValues.PART_QUESTIONS)).length !== 0) { + console.log("A") return true; } + console.log("B") return false; }, resetDependentState() { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 6c0f305b5..93435b82a 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -8,7 +8,7 @@
- @@ -132,7 +132,6 @@ import loadingModal from '@/common-components/loading-modal/loading-modal.vue'; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import store from "@/store"; -import baseMixin from "@/mixins/base-mixin.js"; import { storeActions } from "@/constants/store-actions"; import { storeMutations } from "@/constants/store-mutations"; import { errorMessages } from "@/constants/error-messages"; @@ -317,23 +316,44 @@ export default { this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); this.navigateForward(); }, - navigateForward(){ + async navigateForward(){ if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ - this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {}); + this.$router.navigateAfterSave(this.navigationScenarios.CONTINUING_WITH_DIFFERENT_GLASS, this.$route, {}, { displayVehicleChangeAlert: true }, {}); return; } else { - this.$refs.loadingModal.showModal(); - navigateAfterSaveToHeritageFunnel(this.$route); + // this.$refs.loadingModal.showModal(); + // navigateAfterSaveToHeritageFunnel(this.-$route); + const result = await this.dispatchStoreAction(storeActions.GET_PARTS_OR_QUESTIONS); + const partsOrQuestions = result.data.partsOrQuestions; + const hasPartsQuestions = partsOrQuestions.some(pq => pq.partQuestions?.length > 0); + const hasGlassLocationWithMultipleParts = partsOrQuestions.some(pq => pq.parts?.length > 1); + console.log(partsOrQuestions) + if (hasPartsQuestions) { + console.log("A") + // TODO Header not updating + this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data); + } + else if (hasGlassLocationWithMultipleParts) { + console.log("B") + // this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data); + } + else { + console.log("C") + store.commit(storeMutations.UPDATE_PARTS, partsOrQuestions); + this.$refs.loadingModal.showModal(); + navigateAfterSaveToHeritageFunnel(this.$route); + } + console.log(result) return; } }, validateZip(zip) { - return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, { + return this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { zip, }); }, lookupVehicle(vin) { - return baseMixin.methods.dispatchStoreAction( + return this.dispatchStoreAction( storeActions.LOOKUP_VEHICLE_BY_VIN, { vin } ); diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index d7491a6bf..36fefe7d6 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -8,8 +8,8 @@ const navigationScenarios = { CLICKED_FORWARD: "CLICKED_FORWARD", CLICKED_FORWARD_WITH_VIN: "CLICKED_FORWARD_WITH_VIN", SELECTED_PARTS: "SELECTED_PARTS", - CONTINUING_WITH_PARTS_QUESTION: "CONTINUING_WITH_PARTS_QUESTION", - CONTINUING_WITH_MULTIPLE_PARTS: "CONTINUING_WITH_MULTIPLE_PARTS", + SELECTED_VIN_WITH_PART_QUESTIONS: "SELECTED_VIN_WITH_PART_QUESTIONS", + SELECTED_VIN_WITH_MULTIPLE_PARTS: "SELECTED_VIN_WITH_MULTIPLE_PARTS", CONTINUING_WITH_SINGLE_PART: "CONTINUING_WITH_SINGLE_PART", CONTINUING_WITH_MULTIPLE_VEHICLES: "CONTINUING_WITH_MULTIPLE_VEHICLES", CONTINUING_WITH_DIFFERENT_GLASS: "CONTINUING_WITH_DIFFERENT_GLASS", diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 4c8ef5363..16ad49c80 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -105,12 +105,20 @@ const routingTable = [ destinationFmgPageValue: fmgPageValues.ESTIMATE, }, { - scenario: navigationScenarios.CLICKED_FORWARD, + scenario: navigationScenarios.CONTINUING_WITH_DIFFERENT_GLASS, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, }, { scenario: navigationScenarios.CLICKED_BACK_WITH_VIN, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, + }, + { + scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, + destinationFmgPageValue: fmgPageValues.PART_QUESTIONS + }, + { + scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, + destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS } ], }, diff --git a/src/store/index.js b/src/store/index.js index dda0fab35..96ca97214 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -539,7 +539,17 @@ export const actions = { // Parts API Actions - getPartsOrQuestions(context, { carId, glassArray, zipCode, vin = '' }) { + getPartsOrQuestions(context) { + const vehicle = context.getters.vehicle; + const damage = context.getters.damage; + const order = context.state.order; + + const carId = vehicle.carId; + const glassArray = damage.glassToReplace; + const zipCode = order.serviceLocation.zipCode; + const vin = vehicle.vin; + + console.log({ carId, glassArray, zipCode, vin }) return globalMethods.callHttpClient({ method: endpoints.GetPartsOrQuestions.method, endpoint: endpoints.GetPartsOrQuestions.url,