From 97d347f9c82340f9f12383141e79585b8220f343 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 7 Feb 2023 13:50:24 -0500 Subject: [PATCH] CSR-1077 supporting items changes This was required to get repair orders to load when the customer didn't progress past the parts page to quote. the load wouldn't have any parts and no chips to indicate repair. --- src/layouts/estimate/estimate.vue | 19 +++++++++++++ .../service-package-question.vue | 28 ++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index f46034412..36a52a2ff 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -223,6 +223,25 @@ export default { } else if (this.$store.getters.order.referralNumber?.length === 6) { await this.navigateForwardWithSingleCarMatch(); } else if (this.isRepair) { + const supportingItemsPromise = await this.dispatchStoreAction( + storeActions.GET_SUPPORTING_ITEMS + ); + + const promiseResultMap = [ + { + resultKey: "supportingItems", + promise: supportingItemsPromise, + }, + ]; + + const resultMap = await settleAllPromises(promiseResultMap); + + this.dispatchStoreAction( + this.storeActions.SAVE_SUPPORTING_ITEMS, + resultMap.supportingItems, + false + ); + // call saveSession here - navigateWithSaving saves too late in the flow await saveSession({}); return this.$router.navigateWithoutSaving( diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index 4f543064c..796da19e9 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -42,7 +42,7 @@ export default { }, watch: { availableLineItems() { - if (this.$store.getters.lineItems.supportingItems) { + if (this.$store.getters.lineItems.vaps) { this.selectDefaultPackage(); } }, @@ -212,18 +212,20 @@ export default { selectDefaultPackage() { const vapsFromStore = this.$store.getters.lineItems.vaps; let lowestTierForPackage = packageNames.TIER_ONE; - vapsFromStore.every((vapsItem) => { - let lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem); - if (lowestTierForThisItem === packageNames.TIER_THREE) { - lowestTierForPackage = packageNames.TIER_THREE; - return false; - } else if (lowestTierForThisItem === packageNames.TIER_TWO) { - lowestTierForPackage = packageNames.TIER_TWO; - return true; - } else { - return true; - } - }); + if (vapsFromStore.length > 0) { + vapsFromStore.every((vapsItem) => { + let lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem); + if (lowestTierForThisItem === packageNames.TIER_THREE) { + lowestTierForPackage = packageNames.TIER_THREE; + return false; + } else if (lowestTierForThisItem === packageNames.TIER_TWO) { + lowestTierForPackage = packageNames.TIER_TWO; + return true; + } else { + return true; + } + }); + } this.selectedPackageName = lowestTierForPackage; }, getLowestTierForThisItem(vapsItem) {