CSR-111 Use pageData instead of glassParts to check if vehicle-parts selections have changed

This commit is contained in:
Katie 2022-08-31 11:02:25 -04:00
parent 474df4dea4
commit e10c585abe
2 changed files with 4 additions and 3 deletions

View file

@ -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);

View file

@ -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;