From b2459ffcf69f1f89c0366bd208771b976fcb0e0c Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 18 Feb 2025 13:54:42 -0500 Subject: [PATCH 1/3] CASH-176 CASH-176 clear email/phone field on all pages, not just service zip --- src/layouts/address-lookup/address-lookup.vue | 21 +++++++----- .../license-plate-lookup.vue | 17 +++++++--- src/layouts/vin-lookup/vin-lookup.vue | 34 +++++++++++++------ 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index e069ee48d..08f602fb4 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -357,15 +357,18 @@ export default { false ); - if (vinPagesMixin.methods.isPhoneNumber(this.customerQuestions.emailOrSms)) { - const phone = this.customerQuestions.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); - } else { - await this.dispatchStoreAction( - storeActions.SAVE_EMAIL, - this.customerQuestions.emailOrSms, - false - ); + // if no value due to field being optional, blank both phone and email address + if (!this.customerQuestions.emailOrSms) { + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); + } + else { + if (vinPagesMixin.methods.isPhoneNumber(this.customerQuestions.emailOrSms)) { + const phone = this.customerQuestions.emailOrSms.replace(/[()]/g, ""); + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + } else { + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.customerQuestions.emailOrSms, false); + } } await this.dispatchStoreAction( diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index e1b3f721e..6f6521dde 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -311,11 +311,18 @@ export default { false ); - if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { - const phone = this.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); - } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + // if no value due to field being optional, blank both phone and email address + if (!this.emailOrSms) { + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); + } + else { + if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { + const phone = this.emailOrSms.replace(/[()]/g, ""); + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + } else { + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + } } await this.dispatchStoreAction( diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 82c54d43a..2c93e7182 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -330,11 +330,18 @@ export default { false ); - if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { - const phone = this.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); - } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + // if no value due to field being optional, blank both phone and email address + if (!this.emailOrSms) { + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); + } + else { + if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { + const phone = this.emailOrSms.replace(/[()]/g, ""); + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + } else { + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + } } await this.dispatchStoreAction( @@ -380,11 +387,18 @@ export default { ); } - if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { - const phone = this.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); - } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + // if no value due to field being optional, blank both phone and email address + if (!this.emailOrSms) { + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); + } + else { + if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { + const phone = this.emailOrSms.replace(/[()]/g, ""); + await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + } else { + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + } } await this.dispatchStoreAction( From 72fd8d1a3cf37cdba8850d7bfc777b4abf7a3121 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 19 Feb 2025 13:55:08 -0500 Subject: [PATCH 2/3] Rewrite GetRecalPartNumber(s) helper method --- src/helpers/recal-helper.js | 12 ++++++++++++ src/store/index.js | 24 +++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/helpers/recal-helper.js b/src/helpers/recal-helper.js index c73755e8f..d43da5d34 100644 --- a/src/helpers/recal-helper.js +++ b/src/helpers/recal-helper.js @@ -58,3 +58,15 @@ export function getTopLevelPartsWithRecal(lineItems) { return lineItems.filter((li) => isRecalPartOrHasChildRecalPart(li)); } + +export function getRecalPartNumbers(glassPartsArray) { + if (glassPartsArray && glassPartsArray.length > 0) { + const topLevel = glassPartsArray.filter((gp) => isRecalPart(gp)).map((gp) => gp.partNumber); + + const children = glassPartsArray.map((gp) => getRecalPartNumbers(gp.childParts)).flat(); + + return [...topLevel, ...children]; + } else { + return []; + } +} diff --git a/src/store/index.js b/src/store/index.js index 03e8f339a..d52fea200 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -45,6 +45,7 @@ import { containsRecalParts, getTopLevelPartsWithRecal, isRecalPartOrHasChildRecalPart, + getRecalPartNumbers, } from "@/helpers/recal-helper"; import { externalParameterStatus } from "@/constants/external-parameters"; import { experimentSettings } from "@/constants/experiments"; @@ -1712,10 +1713,15 @@ export const actions = { var endPoint = `${endpoints.GetMobileFeePart.url}/?serviceType=${serviceType}&facilityType=${facilityType}&parentAccountNumber=${parentAccountNumber}&billToAccountNumber=${billToAccountNumber}&providerNumber=${providerNumber}&isItacOptimized=${isItacOptimized}&zipCode=${zipCode}`; - const recalPartNumber = getRecalPartNumber(order.lineItems?.glassParts[0]); + const recalPartNumbers = getRecalPartNumbers(order.lineItems?.glassParts); const carId = order.vehicle?.carId; - if (recalPartNumber && carId) { - endPoint = `${endPoint}&partNumbers=${recalPartNumber}&carId=${carId}`; + if (recalPartNumbers && recalPartNumbers.length > 0 && carId) { + let additionalQueryParams = ``; + for (let i = 0; i < recalPartNumbers.length; i++) { + additionalQueryParams += `&partNumbers[${i}]=4${recalPartNumbers[i]}`; + } + additionalQueryParams += `&carId=${carId}`; + endPoint += additionalQueryParams; } if (coverageStatus) { @@ -3760,15 +3766,3 @@ function getExternalParameterDefaultState() { function saveExternalParameterState(externalParameterState) { window.sessionStorage.setItem("externalParameterState", JSON.stringify(externalParameterState)); } - -//This function finds the recalibration part and returns the part number for it. -function getRecalPartNumber(glassPartsArray) { - const recalPart = glassPartsArray.childParts.find( - (item) => item.partType === partTypeStrings.ADAS_RECALIBRATION - ); - if (recalPart) { - return recalPart.partNumber; - } else { - return null; - } -} From fa48005be0cf2537259d15fc916fa2889c2f378a Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 19 Feb 2025 15:30:04 -0500 Subject: [PATCH 3/3] Fix typo --- src/store/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index d52fea200..7a1f74732 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1718,7 +1718,7 @@ export const actions = { if (recalPartNumbers && recalPartNumbers.length > 0 && carId) { let additionalQueryParams = ``; for (let i = 0; i < recalPartNumbers.length; i++) { - additionalQueryParams += `&partNumbers[${i}]=4${recalPartNumbers[i]}`; + additionalQueryParams += `&partNumbers[${i}]=${recalPartNumbers[i]}`; } additionalQueryParams += `&carId=${carId}`; endPoint += additionalQueryParams;