Merge pull request #320 from Safelite/feature/digital/SSR-476
Corrected bug where page would crash if part wasn't found in pricing …
This commit is contained in:
commit
cf2da5dc11
2 changed files with 12 additions and 43 deletions
|
|
@ -191,8 +191,6 @@ methods: {
|
||||||
throw new Error("Could not match any parts to the selected parts");
|
throw new Error("Could not match any parts to the selected parts");
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.mainStore.resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts);
|
|
||||||
|
|
||||||
this.navigateForward(matchedParts, null);
|
this.navigateForward(matchedParts, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -734,28 +734,6 @@ export const useMainStore = defineStore({
|
||||||
this.order.damage.glassToReplace = null;
|
this.order.damage.glassToReplace = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts) {
|
|
||||||
const partsOrQuestionsDataToCompareWith =
|
|
||||||
this.pageData(issPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ??
|
|
||||||
this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ??
|
|
||||||
[];
|
|
||||||
|
|
||||||
const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith);
|
|
||||||
const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts);
|
|
||||||
|
|
||||||
const haveSelectedVehiclePartsChanged =
|
|
||||||
previouslySelectedPartNumbers !== currentlySelectedPartNumbers;
|
|
||||||
|
|
||||||
if (haveSelectedVehiclePartsChanged) {
|
|
||||||
//was updateGlassParts, added dependencies for SSR-290
|
|
||||||
this.resetPartsAndDependencies();
|
|
||||||
this.updateMoldingQuestionAnswers(null);
|
|
||||||
this.updateCapabilityQuestionAnswers(null);
|
|
||||||
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null });
|
|
||||||
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
resetISSConfigState() {
|
resetISSConfigState() {
|
||||||
this.issConfig.clientName = 'Generic Insurance';
|
this.issConfig.clientName = 'Generic Insurance';
|
||||||
this.issConfig.clientDisplayName = 'Generic Insurance';
|
this.issConfig.clientDisplayName = 'Generic Insurance';
|
||||||
|
|
@ -1358,30 +1336,23 @@ function convertGlassPieceNamingFromApi(glassArray) {
|
||||||
return glassArray;
|
return glassArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(',')
|
|
||||||
: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function addPricesToLineItems(lineItems, pricingLineItems) {
|
function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||||
lineItems.forEach((lineItem) => {
|
lineItems.forEach((lineItem) => {
|
||||||
const lineItemIndex = pricingLineItems.findIndex(
|
|
||||||
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
|
||||||
);
|
|
||||||
if (lineItem.childParts) {
|
if (lineItem.childParts) {
|
||||||
addPricesToLineItems(lineItem.childParts, pricingLineItems);
|
addPricesToLineItems(lineItem.childParts, pricingLineItems);
|
||||||
}
|
}
|
||||||
const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0];
|
|
||||||
lineItem.laborAmount = pricedLineItem.laborAmount;
|
const lineItemIndex = pricingLineItems.findIndex(
|
||||||
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
||||||
lineItem.kitPrice = pricedLineItem.kitPrice;
|
);
|
||||||
|
|
||||||
|
if(lineItemIndex > -1)
|
||||||
|
{
|
||||||
|
const pricedLineItem = pricingLineItems[lineItemIndex];
|
||||||
|
lineItem.laborAmount = pricedLineItem.laborAmount;
|
||||||
|
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||||
|
lineItem.kitPrice = pricedLineItem.kitPrice;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return lineItems;
|
return lineItems;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue