It has more layout page linting and I have removed (really re-removed) the reduntant router parms.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const hasPrice = (lineItem) => {
|
|
const value = (!!lineItem?.kitPrice && lineItem.kitPrice !== 0)
|
|
|| (!!lineItem?.laborAmount && lineItem.laborAmount !== 0)
|
|
|| (!!lineItem?.sellingPrice && lineItem.sellingPrice !== 0);
|
|
return value;
|
|
};
|
|
|
|
const processLineItems = (lineItems) => {
|
|
let returnVal = true;
|
|
lineItems.forEach((lineItem) => {
|
|
if (!hasPrice(lineItem)) {
|
|
returnVal = false;
|
|
}
|
|
});
|
|
return returnVal;
|
|
};
|
|
|
|
const allGlassPartsAndItemsHavePrices = (lineItems) => {
|
|
if (lineItems.glassParts && Array.isArray(lineItems.glassParts)) {
|
|
if (!processLineItems(lineItems.glassParts)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (lineItems.supportingItems && Array.isArray(lineItems.supportingItems)) {
|
|
if (!processLineItems(lineItems.supportingItems)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (lineItems.vaps && Array.isArray(lineItems.vaps)) {
|
|
if (!processLineItems(lineItems.vaps)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
export default allGlassPartsAndItemsHavePrices;
|