From b0bef5b5e235dd91e67f9b6c94db91d67518d9c9 Mon Sep 17 00:00:00 2001 From: Jason Wheeler Date: Wed, 11 Jan 2023 16:01:31 -0500 Subject: [PATCH] everything is converted over but it needs tested now --- src/constants/endpoints.js | 7 ++++ src/layouts/address-lookup/address-lookup.vue | 20 ++++----- .../address-questions/address-questions.vue | 7 ++-- src/router/router-constants/routing-table.js | 41 ++++++++++++++++++- src/store/index.js | 16 +++++++- 5 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index b2df065d..b469bb67 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -63,6 +63,10 @@ const endpoints = { url: "/vehicle/api/v1/vehicle/lookup", method: "POST", }, + LookupVinByAddress: { + url: "/vehicle/api/v1/vehicle/lookup-vin-by-address", + method: "POST", + }, InitializeSession: { url: "/analytics/api/v1/analytics/initialize", method: "POST", @@ -79,6 +83,9 @@ const endpoints = { url: "/location/api/v1/location/zip", method: "GET", }, + GooglePlaces: { + url: "https://maps.googleapis.com/maps/api/js?key={apiKey}&libraries=places" + } }; export { endpoints }; diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 8558f182..761863a9 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -193,6 +193,7 @@ export default { this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, attachCustomEvents() { + this.prependActionToMethod(this, this.forwardButtonAction, () => { this.pushEventToGA( this.$route.query[this.queryStrings.ISS_PAGE], @@ -201,6 +202,7 @@ export default { true ); }); + }, async forwardButtonAction() { @@ -209,19 +211,13 @@ export default { // Vehicle info change in the flow, use a variable to keep track and commit to state at the end. let vehicleInfoToCommit = {}; - //Todo: Look up VIN by address - /* - const vinLookupResponse = this.dispatchStoreAction( - storeActions.LOOKUP_VIN_BY_ADDRESS, - { + const vinLookupResponse = useMainStore().lookupVinByAddress ({ 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 = [ @@ -260,7 +256,7 @@ export default { // Single VIN found const carFound = carsFound[0].vehicle; - this.isCarIdDifferent = carFound.carId !== this.mainStore.order.vehicle.carId; + this.isCarIdDifferent = carFound.carId !== useMainStore().order.vehicle.carId; if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) { // Display Alert this.previouslyEnteredCarId = carFound.carId; @@ -348,7 +344,7 @@ export default { async navigateForward(carsFound) { // Match vehicles found to vehicles in state. const matchingCars = carsFound.filter( - (car) => car.vehicle.carId === this.mainStore.order.vehicle.carId + (car) => car.vehicle.carId === useMainStore().order.vehicle.carId ); // If a different vehicle is found than the one entered and the selected glass is not available for that vehicle then navigate back to "vehicle-damage" @@ -358,7 +354,7 @@ export default { !this.isSelectedGlassAvailableForVehicle && matchingCars.length === 1 ) { - this.$router.navigateWithSaving( + this.$router.navigate( this.navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, this.$route, {}, @@ -367,7 +363,7 @@ export default { } else if (matchingCars.length === 1) { await this.navigateForwardWithSingleCarMatch(); } else { - this.$router.navigateWithSaving( + this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, this.$route, {}, diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue index 3b05fc33..633d20bb 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue @@ -78,7 +78,8 @@ import { applicationConfig } from "@/constants/application-config.js"; import { defineRule } from "vee-validate"; import { required, regex } from "@/helpers/validation-rules"; import { errorMessages } from "@/constants/error-messages"; -import { states } from "@/constants/states" +import { states } from "@/constants/states"; +import { endpoints } from '@/constants/endpoints'; // DEFINE VALIDATION RULES defineRule("street-address-required", required(errorMessages.STREET_ADDRESS_REQUIRED)); @@ -147,10 +148,10 @@ export default { const addressField1 = document.getElementById("autocomplete"); const self = this; - const apiKey = applicationConfig.GOOGLE_PLACES_API_KEY; + const url = endpoints.GooglePlaces.url.replace("{apiKey}", applicationConfig.GOOGLE_PLACES_API_KEY) this.$loadScript( - `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places` + url ) .then(() => { // Script is loaded, initialize the autocomplete textbox diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 3d15d67b..ac0b0d95 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -222,7 +222,44 @@ const routingTable = function(store) { destinationIssPageValue: issPageValues.QUOTE, }, ], - }, + }, + { + issPageValue: issPageValues.ADDRESS_LOOKUP, + maps: [ + { + scenario: navigationScenarios.CLICKED_BACK, + destinationIssPageValue: issPageValues.VEHICLE_LOOKUP, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES, + destinationIssPageValue: issPageValues.ADDRESS_VEHICLES, + }, + { + scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, + destinationIssPageValue: issPageValues.VEHICLE_PARTS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS, + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, + destinationIssPageValue: issPageValues.QUOTE, + }, + ], + }, { issPageValue: issPageValues.WELCOME_PAGE, maps: [ @@ -236,7 +273,7 @@ const routingTable = function(store) { } ] }, - + ]; }; diff --git a/src/store/index.js b/src/store/index.js index 211781b4..32fe6bc3 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -172,7 +172,21 @@ export const useMainStore = defineStore({ }, actions: { - // Content API Actions + // Content API Actions + + lookupVinByAddress({ licenseLastName, licenseStreetAddress, licenseZip, licenseState }) { + return globalMethods.callHttpClient({ + method: endpoints.LookupVinByAddress.method, + endpoint: endpoints.LookupVinByAddress.url, + payload: { + licenseLastName: licenseLastName, + licenseStreetAddress: licenseStreetAddress, + licenseZip: licenseZip, + licenseState: licenseState, + }, + }); + }, + getRouteInfo(pageName) { return globalMethods.callHttpClient({ method: endpoints.GetRouteInfo.method,