diff --git a/src/store/index.js b/src/store/index.js index f8311636..e369493f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -374,52 +374,58 @@ export const useMainStore = defineStore({ duration: readableDuration }; }, - experimentOrder: (state) => ({ - funnelVehicleYear: state.order.vehicle.year, - funnelVehicleMake: state.order.vehicle.make, - funnelVehicleModel: state.order.vehicle.model, - funnelVehicleStyle: state.order.vehicle.style, - funnelIsRepair: state.order.damage.isRepair, - funnelNumberOfChips: state.order.damage.numberOfChips, - funnelCarId: state.order.vehicle.carId, - funnelServiceCity: state.order.serviceLocation.city, - funnelServiceState: state.order.serviceLocation.state, - funnelServiceZipCode: state.order.serviceLocation.zipCode, - funnelServiceZipCodeCtu: state.order.serviceLocation.zipCodeCtu, - funnelParentAccountNumber: state.order.accountNumber, - funnelProviderNumber: state.order.serviceLocation.provider.providerNumber, - funnelIsCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - funnelHasRecalibrationPart: getHasRecalibrationPart(state), - funnelSelectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - 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: [ - ...getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - 'partNumber' - ), - ...getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.otherParts, - 'partNumber' - ) - ], - funnelOrderPartTypes: [ - ...getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - 'recalibrationType' - ), - ...getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.otherParts, - 'recalibrationType' - ) - ] - }), + experimentOrder: (s) => { + const ctuToUse = (s.order.serviceLocation.appointmentType === AppointmentTypeStrings.IN_SHOP + || s.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF) + ? s.order.serviceLocation.zipCodeCtu : s.order.serviceLocation.provider?.address?.zipCodeCtu; + + return { + funnelVehicleYear: s.order.vehicle.year, + funnelVehicleMake: s.order.vehicle.make, + funnelVehicleModel: s.order.vehicle.model, + funnelVehicleStyle: s.order.vehicle.style, + funnelIsRepair: s.order.damage.isRepair, + funnelNumberOfChips: s.order.damage.numberOfChips, + funnelCarId: s.order.vehicle.carId, + funnelServiceCity: s.order.serviceLocation.city, + funnelServices: s.order.serviceLocation.state, + funnelServiceZipCode: s.order.serviceLocation.zipCode, + funnelServiceZipCodeCtu: ctuToUse, + funnelParentAccountNumber: s.order.accountNumber, + funnelProviderNumber: s.order.serviceLocation.provider.providerNumber, + funnelIsCoverageVerified: s.order.payment.insuranceCoverage.isVerified, + funnelHasRecalibrationPart: getHasRecalibrationPart(s), + funnelSelectedMultiGlass: s.order.damage.glassToReplace?.length > 1, + funnelSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects(s.order.damage.glassToReplace, 'glassLocation') + .includes(damageLocationsSelected.WINDSHIELD), + funnelSelectedBackGlass: getNonFalseValuesOfPropertyInArrayOfObjects(s.order.damage.glassToReplace, 'glassLocation') + .includes(damageLocationsSelected.REAR), + funnelSelectedDriverSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(s.order.damage.glassToReplace, 'glassLocation') + .includes(damageLocationsSelected.DRIVER), + funnelSelectedPassengerSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(s.order.damage.glassToReplace, 'glassLocation') + .includes(damageLocationsSelected.PASSENGER), + funnelOrderPartNumbers: [ + ...getNonFalseValuesOfPropertyInArrayOfObjects( + s.order.lineItems.glassParts, + 'partNumber' + ), + ...getNonFalseValuesOfPropertyInArrayOfObjects( + s.order.lineItems.otherParts, + 'partNumber' + ) + ], + funnelOrderPartTypes: [ + ...getNonFalseValuesOfPropertyInArrayOfObjects( + s.order.lineItems.glassParts, + 'recalibrationType' + ), + ...getNonFalseValuesOfPropertyInArrayOfObjects( + s.order.lineItems.otherParts, + 'recalibrationType' + ) + ] + }; + }, experimentSettings: (state) => state.applicationUser.experiments .filter((x) => !!x.isActive) .map((x) => x.settings)