From 29c71257838e5545919d0554d08765d6ada2f4ce Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Mon, 30 Sep 2024 13:40:12 -0400 Subject: [PATCH 1/5] Updates for getting recal parts as child parts --- src/constants/endpoints.js | 13 ++++++ .../coverage-statement/coverage-statement.vue | 5 +++ src/layouts/vehicle-damage/vehicle-damage.vue | 4 +- src/store/index.js | 45 +++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index f6ac757a..5c25364c 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -104,6 +104,19 @@ const endpoints = Object.freeze({ url: `${PARTS_BASE_URL}/rain-defense`, method: 'GET' }, + GetRecalParts: { + url: ( + carId, + partNumber, + recalibrationType, + parentAccountNumber, + zipCode, + applicationName, + referralSequenceNumber + // eslint-disable-next-line max-len + ) => `${PARTS_BASE_URL}/recal-parts/${carId}/${partNumber}/${recalibrationType}/${parentAccountNumber}/${zipCode}/${applicationName}/${referralSequenceNumber}`, + method: 'GET' + }, GetSupportingItems: { url: `${PARTS_BASE_URL}/supporting-items`, method: 'POST' diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index 136198a2..2b90a4e8 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -159,6 +159,7 @@ export default { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage); const supportingItemsPromise = store.getSupportingItems(); + const getRecalPartsPromise = store.getRecalParts(); // Settle promises and get results const promiseResultMap = [ @@ -169,6 +170,10 @@ export default { { resultKey: 'supportingItems', promise: supportingItemsPromise + }, + { + resultKey: 'recalParts', + promise: getRecalPartsPromise } ]; diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index de8250ed..2ca0efe1 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -414,8 +414,8 @@ export default { ); if (this.isWindshieldRepair) { - const supportingItems = - await useMainStore().getSupportingItems(); + await useMainStore().getRecalParts(); + const supportingItems = await useMainStore().getSupportingItems(); useMainStore().updateSupportingItems(supportingItems.data); } diff --git a/src/store/index.js b/src/store/index.js index 312912d9..0aa5d4ab 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1020,6 +1020,51 @@ export const useMainStore = defineStore({ }).catch((error) => reject(error)); }); }, + async getRecalParts() { + const { glassParts } = this.lineItems; + const { carId } = this.vehicle; + const { parentAccountNumber, referralSequenceNumber } = this.order; + const { zipCode } = this.order.serviceLocation; + + if (glassParts && glassParts.length > 0) { + glassParts.forEach((glassPart) => { + if (glassPart.requiresRecalibration) { + const partNumberChecked = glassPart.partNumber; + globalMethods + .callHttpClient({ + method: endpoints.GetRecalParts.method, + endpoint: endpoints.GetRecalParts.url( + carId, + partNumberChecked, + glassPart.recalibrationType, + parentAccountNumber, + zipCode, + applicationConfig.APPLICATION_NAME, + referralSequenceNumber + ) + }) + .then((response) => { + const recalResponse = response.data; + if (recalResponse && recalResponse.recalibrationParts && recalResponse.recalibrationParts.length > 0) { + this.addGlassPartRecalibrationInfo(partNumberChecked, recalResponse.recalibrationParts[0]); + } + }); + } + }); + } + }, + addGlassPartRecalibrationInfo(partNumber, recalPartInformation) { + const glassPart = this.lineItems.glassParts.find((gp) => gp.partNumber === partNumber); + if (glassPart) { + const recalChildPart = glassPart.childParts?.find((cp) => cp.partNumber === recalPartInformation.partNumber); + if (!recalChildPart) { + if (!Array.isArray(glassPart.childParts) || !glassPart.childParts.length) { + glassPart.childParts = []; + } + glassPart.childParts.push(recalPartInformation); + } + } + }, async getSupportingItems() { const { glassParts } = this.lineItems; const { carId } = this.vehicle; From bc6b31c7902209e6e638726a410cf88470524b16 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 1 Oct 2024 13:27:37 -0400 Subject: [PATCH 2/5] PR updates --- src/layouts/vehicle-damage/vehicle-damage.vue | 4 ++-- src/store/index.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 2ca0efe1..1561a3bd 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -414,8 +414,8 @@ export default { ); if (this.isWindshieldRepair) { - await useMainStore().getRecalParts(); - const supportingItems = await useMainStore().getSupportingItems(); + const results = await Promise.allSettled([useMainStore().getSupportingItems(), useMainStore().getRecalParts()]); + const supportingItems = results[0]; useMainStore().updateSupportingItems(supportingItems.data); } diff --git a/src/store/index.js b/src/store/index.js index 0aa5d4ab..d0e6f37a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1027,10 +1027,11 @@ export const useMainStore = defineStore({ const { zipCode } = this.order.serviceLocation; if (glassParts && glassParts.length > 0) { + const recalPromises = []; glassParts.forEach((glassPart) => { if (glassPart.requiresRecalibration) { const partNumberChecked = glassPart.partNumber; - globalMethods + recalPromises.push(globalMethods .callHttpClient({ method: endpoints.GetRecalParts.method, endpoint: endpoints.GetRecalParts.url( @@ -1048,9 +1049,10 @@ export const useMainStore = defineStore({ if (recalResponse && recalResponse.recalibrationParts && recalResponse.recalibrationParts.length > 0) { this.addGlassPartRecalibrationInfo(partNumberChecked, recalResponse.recalibrationParts[0]); } - }); + })); } }); + Promise.allSettled(recalPromises); } }, addGlassPartRecalibrationInfo(partNumber, recalPartInformation) { @@ -1070,6 +1072,8 @@ export const useMainStore = defineStore({ const { carId } = this.vehicle; const { isRepair, numberOfChips } = this.damage; + console.log('supporting http response..'); + return globalMethods .callHttpClient({ method: endpoints.GetSupportingItems.method, @@ -1257,7 +1261,7 @@ export const useMainStore = defineStore({ facilityType: 'Mobile', parentAccountNumber: this.order.parentAccountNumber, billToAccountNumber: this.billToAccountNumber, - isItacOptimized: false, //TODO: Implement with response from getITACPriceOrderItems + isItacOptimized: false, // TODO: Implement with response from getITACPriceOrderItems providerNumber: this.providerNumber, carId: vehicle.carId, coverageStatus: coverageStatuses.mapToApi(insuranceCoverage.coverageStatus), From 3e636a91d7f5db4b249b7c684623d02876459d5d Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 1 Oct 2024 14:12:33 -0400 Subject: [PATCH 3/5] whoops --- vue.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vue.config.js b/vue.config.js index b3ee3bb7..5a12dca9 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.dev.safelite.io'; +process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.test.safelite.io'; process.env.VUE_APP_CURRENT_ENVIRONMENT = 'Localhost'; process.env.VUE_APP_CUSTOMER_PORTAL_URL = 'https://myaccountdev.safelite.com/'; process.env.VUE_APP_GOOGLE_PLACES_API_KEY = 'AIzaSyCuLhQcDdZTTb4JzpUFms1OCch2dk5lHF0'; From 3b6ad207f5bd13a86fa667c787a34e556100a369 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 1 Oct 2024 15:27:16 -0400 Subject: [PATCH 4/5] Revert "whoops" This reverts commit 3e636a91d7f5db4b249b7c684623d02876459d5d. --- vue.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vue.config.js b/vue.config.js index 5a12dca9..b3ee3bb7 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.test.safelite.io'; +process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.dev.safelite.io'; process.env.VUE_APP_CURRENT_ENVIRONMENT = 'Localhost'; process.env.VUE_APP_CUSTOMER_PORTAL_URL = 'https://myaccountdev.safelite.com/'; process.env.VUE_APP_GOOGLE_PLACES_API_KEY = 'AIzaSyCuLhQcDdZTTb4JzpUFms1OCch2dk5lHF0'; From 06ef9ae7a3a8bedfe054a5dd636ffae6d3a95c3c Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 1 Oct 2024 15:27:36 -0400 Subject: [PATCH 5/5] whoops part 2 --- 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 d0e6f37a..78321758 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1052,7 +1052,7 @@ export const useMainStore = defineStore({ })); } }); - Promise.allSettled(recalPromises); + await Promise.allSettled(recalPromises); } }, addGlassPartRecalibrationInfo(partNumber, recalPartInformation) {