Update store getters for recal

This commit is contained in:
Chloe Herd 2024-09-17 13:45:32 -04:00
parent e30f2631e5
commit 1dde9eb6f7

View file

@ -39,6 +39,7 @@ import {
coverageType,
coverageTypeValue,
} from "@/constants/insurance";
import { containsRecalParts } from "@/helpers/recal-helper";
// Export State
const getDefaultState = () => {
@ -2421,8 +2422,9 @@ export const actions = {
}));
const order = context.getters.order;
var providerNumber = order.serviceLocation?.provider?.providerNumber ?? order.serviceLocation?.zipCodeCtu;
var providerNumber =
order.serviceLocation?.provider?.providerNumber ?? order.serviceLocation?.zipCodeCtu;
if (providerNumber.startsWith("00")) {
providerNumber = providerNumber.substring(1);
}
@ -2912,34 +2914,7 @@ export default createStore({
// Private Functions
function getHasRecalibrationPart(state) {
var hasRequiresRecalibration =
getNonFalseValuesOfPropertyInArrayOfObjects(
state.order.lineItems.glassParts,
"requiresRecalibration"
)?.length > 0;
var hasRecalibrationType =
getNonFalseValuesOfPropertyInArrayOfObjects(
state.order.lineItems.glassParts,
"recalibrationType"
)?.length > 0;
if (hasRequiresRecalibration) {
if (hasRecalibrationType) {
// Has both 'requiresRecalibration' and 'recalibrationType' and 'recalibrationType'
return (
getNonFalseValuesOfPropertyInArrayOfObjects(
state.order.lineItems.glassParts,
"recalibrationType"
)[0].toLowerCase() != "unknown"
);
} else {
// Has 'requiresRecalibration' but no 'recalibrationType' at all
return true;
}
} else {
// Does not have 'requiresRecalibration'
return false;
}
return containsRecalParts(state.order.lineItems);
}
function sortArrayOfObjectsByPropertyValue(arrayOfObjects, propertyName) {