From e10c585abe749d2c925006a87d9c551893af6193 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 31 Aug 2022 11:02:25 -0400 Subject: [PATCH] CSR-111 Use pageData instead of glassParts to check if vehicle-parts selections have changed --- src/mixins/vehicle-questions-mixin.js | 2 +- src/store/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 06776174f..616c1fb5e 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -122,7 +122,7 @@ export default { } }, backButtonAction() { - const partsOrQuestions = this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS)?.partsOrQuestions; + const partsOrQuestions = (this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS) ?? this.$store.getters.pageData(fmgPageValues.VEHICLE_PARTS))?.partsOrQuestions; const hasPartQuestions = this.hasPartQuestions(partsOrQuestions); const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(partsOrQuestions); const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions); diff --git a/src/store/index.js b/src/store/index.js index e7db95ee2..cfb5e1dff 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1020,14 +1020,15 @@ export const actions = { }, resetMoldingAndCapabilityQuestionAnswersIfNeeded(context, matchedParts) { const previousResultsArray = [{ parts: context.getters.lineItems.glassParts }]; - + const partsOrQuestionsDataToCompareWith = context.getters.pageData(fmgPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ?? context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ?? []; + function getAllPartNumbers(partsOrQuestions) { return partsOrQuestions[0].parts ? [...partsOrQuestions].map(glass => glass.parts).flat().map(part => part.partNumber).filter(partNumber => !partNumber.toUpperCase().includes("FEE")).sort().join(",") : [] } - const previouslySelectedPartNumbers = getAllPartNumbers(previousResultsArray); + const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith); const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts); const haveSelectedVehiclePartsChanged = previouslySelectedPartNumbers !== currentlySelectedPartNumbers;