INSR-9513: Add all recal parts to glass part child parts array

This commit is contained in:
Alex Humphries 2026-05-04 15:08:52 -04:00
parent 3d72aa36c9
commit 4fbca5ccd8

View file

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