Merge pull request #719 from Safelite/defect/CSR-820

CSR-820 | Fix for hasRecalibrationPart
This commit is contained in:
scottkiener 2022-09-07 09:55:36 -04:00 committed by GitHub
commit 9cae80af61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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