From 7304729717eea21de083d3614078205e631004c7 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 1 Mar 2023 10:09:45 -0500 Subject: [PATCH 1/2] CSR-969 Hide the home address lookup if a provided zip is in a state that prohibits it --- src/constants/endpoints.js | 4 ++++ src/constants/store-actions.js | 1 + src/layouts/estimate/estimate.vue | 21 +++++++++++++++++++++ src/store/index.js | 7 +++++++ 4 files changed, 33 insertions(+) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 9f4c60d61..1fc6c2b8f 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -54,6 +54,10 @@ const endpoints = { url: "/vehicle/api/v1/vehicle/lookup-vin-by-address", method: "POST", }, + IsVinByAddressPermissible: { + url: "/vehicle/api/v1/vehicle/is-vin-by-address-permissible", + method: "GET", + }, GetPartsOrQuestions: { url: "/parts/api/v1/parts/parts-or-questions", method: "POST", diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 428280d40..c11356d69 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -13,6 +13,7 @@ const storeActions = { GET_DAMAGE_OPTIONS: "getDamageOptions", GET_EVOX_IMAGE: "getEvoxImage", IS_VIN_OPTIONAL_VEHICLE: "isVinOptionalVehicle", + IS_VIN_BY_ADDRESS_PERMISSIBLE: "isVinByAddressPermissible", // Lookup Actions LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 4eafab25e..893f76cb8 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -112,6 +112,8 @@ import { experimentSettings } from "@/constants/experiments"; import vinPagesMixin from "@/mixins/vin-pages-mixin"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { saveSession } from "@/helpers/heritage-integration/order-helper.js"; +import baseMixin from "@/mixins/base-mixin.js"; +import { queryStrings } from "@/constants/query-strings"; // Define Validation Rules defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); @@ -145,12 +147,25 @@ export default { //Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); + const zip = Object.hasOwn(to.query, queryStrings.ZIP_CODE) ? to.query.zipCode : null; + var vinByAddressPromise; + if (zip) { + vinByAddressPromise = baseMixin.methods.dispatchStoreAction( + storeActions.IS_VIN_BY_ADDRESS_PERMISSIBLE, + zip, false + ); + } + //Settle promises and get results const promiseResultMap = [ { resultKey: "cmsContent", promise: cmsContentPromise, }, + (zip != null && zip != undefined) && { + resultKey: "vinByAddress", + promise: vinByAddressPromise, + }, ]; const resultMap = await settleAllPromises(promiseResultMap); @@ -172,6 +187,12 @@ export default { } } + if (zip){ + var indexToRemove = resultMap.cmsContent.VinLookupMethod.Answers.findIndex(answer => answer.Name === 'HomeAddress') + if (indexToRemove){ + resultMap.cmsContent.VinLookupMethod.Answers.splice(indexToRemove, 1); + } + } vm.setCmsContent(resultMap.cmsContent); }); }, diff --git a/src/store/index.js b/src/store/index.js index 93a3e5a25..f42a950ea 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -530,6 +530,13 @@ export const actions = { }, }); }, + isVinByAddressPermissible(context, zip) { + return globalMethods.callHttpClient({ + method: endpoints.IsVinByAddressPermissible.method, + endpoint: `${endpoints.IsVinByAddressPermissible.url}?zipcode=${zip}`, + payload: {}, + }); + }, getVehicleMakes(context, { year }) { return globalMethods.callHttpClient({ method: endpoints.GetVehicleMakes.method, From afcd713fdba5ef835c86245d8979d2dfb9ae2a56 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 1 Mar 2023 11:35:40 -0500 Subject: [PATCH 2/2] CSR-969 prettier --- src/layouts/estimate/estimate.vue | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index 893f76cb8..722357e62 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -152,7 +152,8 @@ export default { if (zip) { vinByAddressPromise = baseMixin.methods.dispatchStoreAction( storeActions.IS_VIN_BY_ADDRESS_PERMISSIBLE, - zip, false + zip, + false ); } @@ -162,10 +163,11 @@ export default { resultKey: "cmsContent", promise: cmsContentPromise, }, - (zip != null && zip != undefined) && { - resultKey: "vinByAddress", - promise: vinByAddressPromise, - }, + zip != null && + zip != undefined && { + resultKey: "vinByAddress", + promise: vinByAddressPromise, + }, ]; const resultMap = await settleAllPromises(promiseResultMap); @@ -187,9 +189,11 @@ export default { } } - if (zip){ - var indexToRemove = resultMap.cmsContent.VinLookupMethod.Answers.findIndex(answer => answer.Name === 'HomeAddress') - if (indexToRemove){ + if (zip) { + var indexToRemove = resultMap.cmsContent.VinLookupMethod.Answers.findIndex( + (answer) => answer.Name === "HomeAddress" + ); + if (indexToRemove) { resultMap.cmsContent.VinLookupMethod.Answers.splice(indexToRemove, 1); } }