From 176669e3eb5e2465dd02d9f5b60691b32cb80b8f Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Tue, 30 Apr 2024 11:41:38 -0400 Subject: [PATCH] fix bailout issue, update bailout name --- src/constants/bailoutCode.js | 2 +- src/constants/bailoutMessage.js | 4 +- src/layouts/vehicle-damage/vehicle-damage.vue | 264 +++++++----------- src/layouts/vin-lookup/vin-lookup.vue | 56 ++-- src/router/router-constants/routing-table.js | 4 + 5 files changed, 134 insertions(+), 196 deletions(-) diff --git a/src/constants/bailoutCode.js b/src/constants/bailoutCode.js index 6e562261..402f207e 100644 --- a/src/constants/bailoutCode.js +++ b/src/constants/bailoutCode.js @@ -9,7 +9,7 @@ const bailoutCode = Object.freeze({ TPANotEnabled: 7, RequestCallback: 8, HeavyTruckVehicle: 9, - NoPartsAvailable: 10 + PartDBError: 10 }); export default bailoutCode; diff --git a/src/constants/bailoutMessage.js b/src/constants/bailoutMessage.js index d18d4a3a..0eb7ea25 100644 --- a/src/constants/bailoutMessage.js +++ b/src/constants/bailoutMessage.js @@ -53,8 +53,8 @@ const bailoutMessage = Object.freeze({ code: bailoutCode.HeavyTruckVehicle, message: `User selected a heavy truck vehicle. Car ID: ${carId} ` }), - NoPartsAvailable: (error) => ({ - code: bailoutCode.NoPartsAvailable, + PartDBError: (error) => ({ + code: bailoutCode.PartDBError, message: `An error occurred in getPartsOrQuestions. Error: ${getItemData(error)}` }) }); diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 75094683..6d7a8715 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -143,7 +143,7 @@ export default { replaceOptionsQuestion, // eslint-disable-next-line vue/no-reserved-component-names Form, - alert, + alert }, mixins: [BaseFormMixin, vehicleQuestionsMixin], async beforeRouteEnter(to, from, next) { @@ -151,20 +151,18 @@ export default { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); - const damageOptionsPromise = store.getDamageOptions( - store.order.vehicle.carId - ); + const damageOptionsPromise = store.getDamageOptions(store.order.vehicle.carId); // Settle promises and get results const promiseResultMap = [ { resultKey: 'cmsContent', - promise: cmsContentPromise, + promise: cmsContentPromise }, { resultKey: 'damageOptions', - promise: damageOptionsPromise, - }, + promise: damageOptionsPromise + } ]; const resultMap = await settleAllPromises(promiseResultMap); @@ -172,23 +170,17 @@ export default { // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); - vm.$refs.damageLocation.initializeComponent( - resultMap.damageOptions - ); + vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions); vm.$refs.sideDoorOptions.initializeComponent( resultMap.damageOptions.driverSideOptions .availableReplacementOptions, resultMap.damageOptions.passengerSideOptions .availableReplacementOptions ); - vm.$refs.windshieldOptions.initializeComponent( - resultMap.damageOptions.windshieldOptions - .availableReplacementOptions - ); - vm.$refs.backGlassOptions.initializeComponent( - resultMap.damageOptions.backGlassOptions - .availableReplacementOptions - ); + vm.$refs.windshieldOptions.initializeComponent(resultMap.damageOptions.windshieldOptions + .availableReplacementOptions); + vm.$refs.backGlassOptions.initializeComponent(resultMap.damageOptions.backGlassOptions + .availableReplacementOptions); }); }, setup() { @@ -204,7 +196,7 @@ export default { selectedDriverSideReplaceOptions: this.getDriverSideReplaceOptionsFromStore(), selectedPassengerSideReplaceOptions: - this.getPassengerSideReplaceOptionsFromStore(), + this.getPassengerSideReplaceOptionsFromStore() }, selectedWindshieldOptions: this.getWindshieldOptionsFromStore(), selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(), @@ -213,83 +205,66 @@ export default { }, computed: { isWindshieldDamageLocation() { - return this.selectedDamageLocations.some( - (selectedDamages) => - selectedDamages.toUpperCase() === - damageLocationsCms.WINDSHIELD - ); + return this.selectedDamageLocations.some((selectedDamages) => + selectedDamages.toUpperCase() + === damageLocationsCms.WINDSHIELD); }, isSideDoorDamageLocation() { - return this.selectedDamageLocations.some( - (selectedDamages) => - selectedDamages.toUpperCase() === - damageLocationsCms.SIDEDOOR - ); + return this.selectedDamageLocations.some((selectedDamages) => + selectedDamages.toUpperCase() + === damageLocationsCms.SIDEDOOR); }, isRearWindowDamageLocation() { - return this.selectedDamageLocations.some( - (selectedDamages) => - selectedDamages.toUpperCase() === - damageLocationsCms.REARWINDOW - ); + return this.selectedDamageLocations.some((selectedDamages) => + selectedDamages.toUpperCase() + === damageLocationsCms.REARWINDOW); }, isWindshieldRepair() { return ( - this.isWindshieldDamageLocation && - this.selectedWindshieldOptions.selectedWindshieldDamageType === - damageLocationsSelected.REPAIR + this.isWindshieldDamageLocation + && this.selectedWindshieldOptions.selectedWindshieldDamageType + === damageLocationsSelected.REPAIR ); }, isDriverSideReplace() { if (!this.isSideDoorDamageLocation) return false; - return this.sideDoorOptionsData.selectedDoorSides.some( - (selectedDriverSide) => - selectedDriverSide.toUpperCase() === - damageLocationsCms.DRIVERSIDE - ); + return this.sideDoorOptionsData.selectedDoorSides.some((selectedDriverSide) => + selectedDriverSide.toUpperCase() + === damageLocationsCms.DRIVERSIDE); }, isPassengerSideReplace() { if (!this.isSideDoorDamageLocation) return false; - return this.sideDoorOptionsData.selectedDoorSides.some( - (selectedPassengerSide) => - selectedPassengerSide.toUpperCase() === - damageLocationsCms.PASSENGERSIDE - ); + return this.sideDoorOptionsData.selectedDoorSides.some((selectedPassengerSide) => + selectedPassengerSide.toUpperCase() + === damageLocationsCms.PASSENGERSIDE); }, hasRepairReplaceConflict() { return ( - this.isWindshieldDamageLocation && - this.selectedDamageLocations.length > 1 && - this.isWindshieldRepair + this.isWindshieldDamageLocation + && this.selectedDamageLocations.length > 1 + && this.isWindshieldRepair ); }, hasSplitSingleConflict() { if ( - !this.selectedDamageLocations?.includes('Windshield') || - this.selectedWindshieldOptions.selectedWindshieldDamageType === - damageLocationsSelected.REPAIR || - !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions - ) - return false; + !this.selectedDamageLocations?.includes('Windshield') + || this.selectedWindshieldOptions.selectedWindshieldDamageType + === damageLocationsSelected.REPAIR + || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions + ) return false; return ( - this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some( - (selectedSingleWindshield) => - selectedSingleWindshield.toUpperCase() === - damageLocationsSelected.SINGLE.toUpperCase() - ) && - (this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some( - (selectedDriverWindshield) => - selectedDriverWindshield.toUpperCase() === - damageLocationsSelected.DRIVER.toUpperCase() - ) || - this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some( - (selectedPassengerWindshield) => - selectedPassengerWindshield.toUpperCase() === - damageLocationsSelected.PASSENGER.toUpperCase() - )) + this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedSingleWindshield) => + selectedSingleWindshield.toUpperCase() + === damageLocationsSelected.SINGLE.toUpperCase()) + && (this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedDriverWindshield) => + selectedDriverWindshield.toUpperCase() + === damageLocationsSelected.DRIVER.toUpperCase()) + || this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedPassengerWindshield) => + selectedPassengerWindshield.toUpperCase() + === damageLocationsSelected.PASSENGER.toUpperCase())) ); }, shouldDisplayVehicleChangeAlert() { @@ -309,32 +284,26 @@ export default { const glassSelections = []; if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.WINDSHIELD - ) || - this.mainStore.order.damage.isRepair + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.WINDSHIELD) + || this.mainStore.order.damage.isRepair ) { glassSelections.push(damageLocationsSelected.WINDSHIELD); } if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.DRIVER || - glass.glassLocation === - damageLocationsSelected.PASSENGER - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.DRIVER + || glass.glassLocation + === damageLocationsSelected.PASSENGER) ) { glassSelections.push(damageLocationsSelected.SIDEDOOR); } if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === damageLocationsSelected.REAR - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation === damageLocationsSelected.REAR) ) { glassSelections.push(damageLocationsSelected.REARWINDOW); } @@ -345,11 +314,10 @@ export default { const windShieldOptions = { selectedWindshieldDamageType: '', selectedWindshieldChipCount: null, - selectedWindshieldReplaceOptions: [], + selectedWindshieldReplaceOptions: [] }; - if (this.mainStore.order.damage.isRepair === undefined) - return windshieldOptions; + if (this.mainStore.order.damage.isRepair === undefined) return windshieldOptions; if (this.mainStore.order.damage.isRepair) { windShieldOptions.selectedWindshieldDamageType = @@ -358,49 +326,37 @@ export default { this.mainStore.order.damage.numberOfChips; } else { if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.WINDSHIELD && - glass.glassName === damageLocationsSelected.SINGLE - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.WINDSHIELD + && glass.glassName === damageLocationsSelected.SINGLE) ) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; - windShieldOptions.selectedWindshieldReplaceOptions.push( - damageLocationsSelected.SINGLE - ); + windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE); } if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.WINDSHIELD && - glass.glassName === damageLocationsSelected.DRIVER - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.WINDSHIELD + && glass.glassName === damageLocationsSelected.DRIVER) ) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; - windShieldOptions.selectedWindshieldReplaceOptions.push( - damageLocationsSelected.DRIVER - ); + windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER); } if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.WINDSHIELD && - glass.glassName === - damageLocationsSelected.PASSENGER - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.WINDSHIELD + && glass.glassName + === damageLocationsSelected.PASSENGER) ) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; - windShieldOptions.selectedWindshieldReplaceOptions.push( - damageLocationsSelected.PASSENGER - ); + windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER); } } @@ -409,20 +365,16 @@ export default { getDoorSidesFromStore() { const doorSides = []; if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === damageLocationsSelected.DRIVER - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation === damageLocationsSelected.DRIVER) ) { doorSides.push(damageLocationsSelected.DRIVERSIDE); } if ( - this.mainStore.order.damage.glassToReplace?.some( - (glass) => - glass.glassLocation === - damageLocationsSelected.PASSENGER - ) + this.mainStore.order.damage.glassToReplace?.some((glass) => + glass.glassLocation + === damageLocationsSelected.PASSENGER) ) { doorSides.push(damageLocationsSelected.PASSENGERSIDE); } @@ -453,10 +405,8 @@ export default { }, getRearReplaceOptionsFromStore() { const rearReplaceOptions = - this.mainStore.order.damage.glassToReplace?.filter( - (glass) => - glass.glassLocation === damageLocationsSelected.REAR - )[0]?.glassName; + this.mainStore.order.damage.glassToReplace?.filter((glass) => + glass.glassLocation === damageLocationsSelected.REAR)[0]?.glassName; return rearReplaceOptions; }, @@ -483,7 +433,7 @@ export default { const partsOrQuestionsResponse = await this.getPartsOrQuestions(); if (partsOrQuestionsResponse.error) { - this.mainStore.setBailout(bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data)); + this.mainStore.setBailout(bailoutMessage.PartDBError(partsOrQuestionsResponse.error.data)); window.console.error('Error on retrieving PartsOrQuestions'); this.$refs.siteFooter.removeLoader(); this.hasBailedOut = true; @@ -512,48 +462,42 @@ export default { selectedGlassToReplace() { const selectedGlassToReplace = []; if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) { - this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach( - (wsItem) => { - selectedGlassToReplace.push({ - glassLocation: damageLocationsSelected.WINDSHIELD, - glassName: wsItem, - }); - } - ); + this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach((wsItem) => { + selectedGlassToReplace.push({ + glassLocation: damageLocationsSelected.WINDSHIELD, + glassName: wsItem + }); + }); } if (this.isDriverSideReplace) { - this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach( - (driverItem) => { - selectedGlassToReplace.push({ - glassLocation: damageLocationsSelected.DRIVER, - glassName: driverItem, - }); - } - ); + this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach((driverItem) => { + selectedGlassToReplace.push({ + glassLocation: damageLocationsSelected.DRIVER, + glassName: driverItem + }); + }); } if (this.isPassengerSideReplace) { - this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach( - (passengerItem) => { - selectedGlassToReplace.push({ - glassLocation: damageLocationsSelected.PASSENGER, - glassName: passengerItem, - }); - } - ); + this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach((passengerItem) => { + selectedGlassToReplace.push({ + glassLocation: damageLocationsSelected.PASSENGER, + glassName: passengerItem + }); + }); } if (this.isRearWindowDamageLocation) { selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.REAR, - glassName: this.selectedRearReplaceOptions, + glassName: this.selectedRearReplaceOptions }); } return selectedGlassToReplace; - }, - }, + } + } }; diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index cfc74792..4bebbe13 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -74,12 +74,12 @@ export default { vehicleBanner, vinLocationInformation, vinLookupAlerts, - vinQuestion, + vinQuestion }, mixins: [baseFormMixin, vehicleQuestionsMixin], provide() { return { - vehicleFromLookup: computed(() => this.vehicleFromLookup), + vehicleFromLookup: computed(() => this.vehicleFromLookup) }; }, async beforeRouteEnter(to, from, next) { @@ -89,8 +89,8 @@ export default { const promiseResultMap = [ { resultKey: 'cmsContent', - promise: cmsContentPromise, - }, + promise: cmsContentPromise + } ]; const resultMap = await settleAllPromises(promiseResultMap); @@ -123,9 +123,9 @@ export default { computed: { isCarIdDifferentFromTheStore() { return ( - this.vehicleFromLookup !== null && - this.hasValidCarId() && - this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId + this.vehicleFromLookup !== null + && this.hasValidCarId() + && this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId ); }, isTwoIdenticalYMMVehicleFound() { @@ -157,10 +157,8 @@ export default { this.resetActiveAlert(); this.$refs.siteFooter.enableForwardAction(); this.needToLookupVehicle = true; - this.$refs.siteFooter.updateButtonText( - this.getCmsContent('SiteFooterWidget', 'ForwardButtonText') - ); - }, + this.$refs.siteFooter.updateButtonText(this.getCmsContent('SiteFooterWidget', 'ForwardButtonText')); + } }, methods: { arePagePrerequisiteValid() { @@ -171,8 +169,8 @@ export default { }, hasValidCarId() { return ( - this.mainStore.vehicle.carId && - this.mainStore.vehicle.carId !== '0' + this.mainStore.vehicle.carId + && this.mainStore.vehicle.carId !== '0' ); }, // NOTE: If form is not valid, this method is not called when 'Continue' button is clicked @@ -182,16 +180,12 @@ export default { this.$refs.siteFooter.enableForwardAction(); if (this.needToLookupVehicle) { - const vehicleLookupResponse = await this.lookupVehicleByVin( - this.vin - ); + const vehicleLookupResponse = await this.lookupVehicleByVin(this.vin); if (vehicleLookupResponse.error) { this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND; - this.mainStore.setBailout( - bailoutMessage.vehicleNotFound(this.vin) - ); + this.mainStore.setBailout(bailoutMessage.vehicleNotFound(this.vin)); this.resetVehicleFromLookup(); this.$refs.siteFooter.removeLoader(); // Temp solution to turn on 'disabled' style on the Continue button @@ -207,7 +201,7 @@ export default { this.vehicleFromLookup = Object.assign( vehicleLookupResponse.data, { - vin: this.vin, + vin: this.vin } ); } @@ -225,9 +219,7 @@ export default { const vehicleYearMakeModelStyle = // eslint-disable-next-line max-len `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model} ${this.forwardButtonCarStyle}`; - this.$refs.siteFooter.updateButtonText( - `Continue with ${vehicleYearMakeModelStyle}` - ); + this.$refs.siteFooter.updateButtonText(`Continue with ${vehicleYearMakeModelStyle}`); this.$refs.siteFooter.removeLoader(); this.needToLookupVehicle = false; @@ -238,15 +230,13 @@ export default { let isSelectedGlassAvailableForVehicle = true; if (this.isCarIdDifferentFromTheStore) { isSelectedGlassAvailableForVehicle = - await isGlassAvailableForCarId( - this.vehicleFromLookup.carId - ); + await isGlassAvailableForCarId(this.vehicleFromLookup.carId); } // navigate back to vehicle-damage if ( - this.isCarIdDifferentFromTheStore && - !isSelectedGlassAvailableForVehicle + this.isCarIdDifferentFromTheStore + && !isSelectedGlassAvailableForVehicle ) { this.mainStore.updateVehicle(this.vehicleFromLookup); this.mainStore.resetDamageState(); @@ -276,7 +266,7 @@ export default { const partsOrQuestionsResponse = await this.getPartsOrQuestions(); if (partsOrQuestionsResponse.error) { - this.mainStore.setBailout(bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data)); + this.mainStore.setBailout(bailoutMessage.PartDBError(partsOrQuestionsResponse.error.data)); window.console.error('Error on retrieving PartsOrQuestions'); this.$refs.siteFooter.removeLoader(); this.hasBailedOut = true; @@ -300,8 +290,8 @@ export default { } catch (responseError) { return { error: { - status: responseError.status, - }, + status: responseError.status + } }; } }, @@ -311,7 +301,7 @@ export default { resetVehicleFromLookup() { this.vehicleFromLookup = null; }, - resetDependentState() {}, - }, + resetDependentState() {} + } }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index a005582f..6a66676d 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -55,6 +55,10 @@ const routingTable = () => [ { scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, destinationIssPageValue: issPageValues.VEHICLE_LOOKUP + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + destinationIssPageValue: issPageValues.BAILOUT_PAGE } ] },