From 7b0afa2eee78ef03719e022af9af4f6dd7e4f1c5 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 7 Sep 2022 09:47:10 -0400 Subject: [PATCH] CSR-820 | Fix for hasRecalibrationPart --- src/store/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index ed6021ed5..ae3b3b006 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -393,7 +393,7 @@ export const getters = { isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, orderPartNumbers: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")], orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], - hasRecalibrationPart: getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "requiresRecalibration")?.length > 0, + hasRecalibrationPart: getHasRecalibrationPart(state), selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, selectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), selectedBackGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), @@ -1110,3 +1110,18 @@ export default createStore({ // Private Functions +function getHasRecalibrationPart(state) { + var hasRequiresRecalibration = getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "requiresRecalibration")?.length > 0; + var hasRecalibrationType = getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType")?.length > 0; + + if (hasRequiresRecalibration) { + if (hasRecalibrationType) { // Has both 'requiresRecalibration' and 'recalibrationType' and 'recalibrationType' + return getAllValuesOfPropertyInArrayOfObjects(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; + } + +} \ No newline at end of file