Add method to get recal parts from glassParts
This commit is contained in:
parent
8f4331107d
commit
4c115a531b
1 changed files with 15 additions and 0 deletions
|
|
@ -25,6 +25,21 @@ export function getTopLevelGlassPartsWithRecal(glassParts) {
|
||||||
return glassParts.filter((gp) => isRecalPartOrHasChildRecalPart(gp));
|
return glassParts.filter((gp) => isRecalPartOrHasChildRecalPart(gp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRecalParts(glassParts) {
|
||||||
|
if (!glassParts) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return glassParts.flatMap((gp) => {
|
||||||
|
if (isRecalPart(gp)) {
|
||||||
|
return [gp];
|
||||||
|
}
|
||||||
|
if (gp.childParts && gp.childParts.length > 0) {
|
||||||
|
return gp.childParts.filter((cp) => isRecalPart(cp));
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getItemsWithoutRecalParts(lineItemsArray) {
|
export function getItemsWithoutRecalParts(lineItemsArray) {
|
||||||
if (!lineItemsArray || !Array.isArray(lineItemsArray)) return null;
|
if (!lineItemsArray || !Array.isArray(lineItemsArray)) return null;
|
||||||
const firstLevelFiltered = deepClone(lineItemsArray).filter((li) => !isRecalPart(li));
|
const firstLevelFiltered = deepClone(lineItemsArray).filter((li) => !isRecalPart(li));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue