diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index 72b66e3e3..cdf69d6fa 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -112,7 +112,7 @@ export default { selectedPartNumber: { get() { - return this.modelValue ? this.modelValue[this.glassLocation][0] : undefined; + return this.modelValue?.partNumber; }, set(newValue) { this.$emit("update:modelValue", this.partsForSelectedTint.filter(part => part.partNumber == newValue)[0]); diff --git a/src/store/index.js b/src/store/index.js index 22283c51b..1d6e68482 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -421,45 +421,15 @@ export const getters = { state.order.payment.insuranceCoverage.isVerified, funnelHasRecalibrationPart: getHasRecalibrationPart(state), funnelSelectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - funnelSelectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects( - state.order.damage.glassToReplace, - "glassLocation" - ).includes(damageLocationsSelected.WINDSHIELD), - funnelSelectedBackGlass: getAllValuesOfPropertyInArrayOfObjects( - state.order.damage.glassToReplace, - "glassLocation" - ).includes(damageLocationsSelected.REAR), - funnelSelectedDriverSideGlass: getAllValuesOfPropertyInArrayOfObjects( - state.order.damage.glassToReplace, - "glassLocation" - ).includes(damageLocationsSelected.DRIVER), - funnelSelectedPassengerSideGlass: getAllValuesOfPropertyInArrayOfObjects( - state.order.damage.glassToReplace, - "glassLocation" - ).includes(damageLocationsSelected.PASSENGER), + funnelSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), + funnelSelectedBackGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), + funnelSelectedDriverSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), + funnelSelectedPassengerSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER), - funnelOrderPartNumbers: [ - ...getAllValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - "partNumber" - ), - ...getAllValuesOfPropertyInArrayOfObjects( - state.order.lineItems.otherParts, - "partNumber" - ), - ], + funnelOrderPartNumbers: [...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")], - funnelOrderPartTypes: [ - ...getAllValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - "recalibrationType" - ), - ...getAllValuesOfPropertyInArrayOfObjects( - state.order.lineItems.otherParts, - "recalibrationType" - ), - ], - }; + funnelOrderPartTypes: [...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], + } }, experimentSettings: (state) => state.applicationUser.experiments @@ -468,8 +438,8 @@ export const getters = { // gaClickInformation: (state) => state.gaClickInformation, }; -function getAllValuesOfPropertyInArrayOfObjects(array, propertyName) { - return (array ?? []).map((x) => x[propertyName]).filter((x) => x); +function getNonFalseValuesOfPropertyInArrayOfObjects(array, propertyName) { + return (array ?? []).map(x => x[propertyName]).filter(x => x); } // Export Actions @@ -1353,28 +1323,13 @@ 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; + 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 ( - getAllValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - "recalibrationType" - )[0].toLowerCase() != "unknown" - ); - } else { - // Has 'requiresRecalibration' but no 'recalibrationType' at all + 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 {