diff --git a/src/store/index.js b/src/store/index.js index e93e62b7..ca323c1c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1120,7 +1120,7 @@ export const useMainStore = defineStore({ .then((response) => { const recalResponse = response.data; if (recalResponse && recalResponse.recalibrationParts && recalResponse.recalibrationParts.length > 0) { - this.addGlassPartRecalibrationInfo(partNumberChecked, recalResponse.recalibrationParts[0]); + this.addGlassPartRecalibrationInfo(partNumberChecked, recalResponse.recalibrationParts); } })); } @@ -1128,15 +1128,18 @@ export const useMainStore = defineStore({ await Promise.allSettled(recalPromises); } }, - addGlassPartRecalibrationInfo(partNumber, recalPartInformation) { + addGlassPartRecalibrationInfo(partNumber, recalPartArray) { 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 = []; + for (const recalPartInformation of recalPartArray) { + const recalChildPart = glassPart.childParts?.find((cp) => cp.partNumber === recalPartInformation.partNumber); + console.log('Existing recalibration child part found', recalChildPart); + if (!recalChildPart) { + if (!Array.isArray(glassPart.childParts) || !glassPart.childParts.length) { + glassPart.childParts = []; + } + glassPart.childParts.push(recalPartInformation); } - glassPart.childParts.push(recalPartInformation); } } },