INSR-9940: hasMSRPart as helper function instead of store getter

This commit is contained in:
Alex Humphries 2026-06-11 12:08:00 -04:00
parent be7b120847
commit ada9e54d09
4 changed files with 10 additions and 4 deletions

View file

@ -1,3 +1,4 @@
import partNumberStrings from '@/constants/part-number-strings';
import partTypeStrings from '@/constants/part-type-strings';
import { deepClone, getNonFalseValuesOfPropertyInArrayOfObjects } from '@/helpers/object-helper';
@ -117,3 +118,7 @@ export function anyPartWithRequiresRecalFlag(lineItems) {
return flattened.some((li) => li.requiresRecalibration === true);
}
export function hasMSRPart(lineItems) {
return lineItems?.feeItems?.some((item) => item.partNumber === partNumberStrings.RECAL_MOBILEDUAL || item.partNumber === partNumberStrings.RECAL_MOBILE) ?? false
}

View file

@ -147,6 +147,7 @@ import {
import { getPriceOfLineItem, getPriceOfLineItems, getTaxOfLineItems } from '@/helpers/price-calculator';
import { processIfStatements } from '@/helpers/cms-content-helper';
import partNumberStrings from '@/constants/part-number-strings';
import { hasMSRPart } from '@/helpers/recal-helper';
const VERIFYING_COVERAGE = 'Verifying coverage';
const ADVANCED_MOBILE_MODAL_REF_NAME = 'advancedMobileModal';
@ -383,7 +384,7 @@ export default {
}
},
hasMSRPart() {
return this.cartOrder.lineItems?.feeItems?.some((item) => item.partNumber === partNumberStrings.RECAL_MOBILEDUAL || item.partNumber === partNumberStrings.RECAL_MOBILE) ?? false;
return hasMSRPart(this.cartOrder.lineItems);
},
includeMobileFeeInCart() {
if (!this.mobileFeeCartItem || this.mobileFeeCartItem.subTotal === 0) {

View file

@ -134,6 +134,7 @@ import widgetFields from '@/constants/cms-widget-fields';
import states from '@/constants/states';
import applicationConfig from '@/constants/application-config';
import { vehicleProtectedAnswers } from '@/constants/contact-details';
import { hasMSRPart } from '@/helpers/recal-helper';
// DEFINE VALIDATION RULES
defineRule('street-address-required', required(errorMessages.SERVICE_ADDRESS_REQUIRED));
@ -228,7 +229,7 @@ export default {
}, {});
},
appointmentInformationWidget() {
return this.mainStore.hasMSRPart ? this.widget.MSRAppointmentInformation : this.widget.appointmentInformation;
return hasMSRPart(this.mainStore.lineItems) ? this.widget.MSRAppointmentInformation : this.widget.appointmentInformation;
}
},
watch: {

View file

@ -454,8 +454,7 @@ export const useMainStore = defineStore({
.reduce((r, c) => Object.assign(r, c), {}) ?? {},
originalDeductible: (state) => (state.order.damage.isRepair ? state.order.originalDeductible.repair : state.order.originalDeductible.replace),
currentDeductible: (state) => (state.order.damage.isRepair ? state.order.currentDeductible.repair : state.order.currentDeductible.replace),
accountNameForEvents: (state) => state.issConfig.clientName,
hasMSRPart: (state) => state.order.lineItems?.feeItems?.some((item) => item.partNumber === partNumberStrings.RECAL_MOBILEDUAL || item.partNumber === partNumberStrings.RECAL_MOBILE) ?? false
accountNameForEvents: (state) => state.issConfig.clientName
},
actions:
{