diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index c47b4e35..06c76f73 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -37,7 +37,7 @@ export default { components: { // eslint-disable-next-line vue/no-reserved-component-names Form, - questionsPageLayout, + questionsPageLayout }, mixins: [baseFormMixin, vehicleQuestionsMixin], async beforeRouteEnter(to, from, next) { @@ -47,8 +47,8 @@ export default { const promiseResultMap = [ { resultKey: 'cmsContent', - promise: cmsContentPromise, - }, + promise: cmsContentPromise + } ]; const resultMap = await settleAllPromises(promiseResultMap); @@ -63,8 +63,8 @@ export default { selectedAnswers: {}, currentGlassIndex: 0, rules: { - optionRequired: globalRules.OPTION_REQUIRED, - }, + optionRequired: globalRules.OPTION_REQUIRED + } }; }, computed: { @@ -83,23 +83,17 @@ export default { partsOrQuestionsData() { return useMainStore().pageData(issPageValues.CAPABILITY_QUESTIONS) .partsOrQuestions; - }, + } }, mounted() { this.getInitialQuestionData(); }, methods: { arePagePrerequisitesValid() { - const capabilityQuestionsFromPageData = useMainStore().pageData( - issPageValues.CAPABILITY_QUESTIONS - ); + const capabilityQuestionsFromPageData = useMainStore().pageData(issPageValues.CAPABILITY_QUESTIONS); return ( - capabilityQuestionsFromPageData?.partsOrQuestions?.some( - (part) => part?.glassName - ) && - capabilityQuestionsFromPageData?.partsOrQuestions?.some( - (part) => part?.capabilityQuestions?.length > 0 - ) + capabilityQuestionsFromPageData?.partsOrQuestions?.some((part) => part?.glassName) + && capabilityQuestionsFromPageData?.partsOrQuestions?.some((part) => part?.capabilityQuestions?.length > 0) ); }, getInitialQuestionData() { @@ -140,9 +134,7 @@ export default { // get answerResult2 of returned answer let selectedAnswerResult2; glass.questions.forEach((q) => { - const idx = q.answers.findIndex( - (a) => a.answerResult === glass.answerData.answerResult - ); + const idx = q.answers.findIndex((a) => a.answerResult === glass.answerData.answerResult); if (idx !== -1) { selectedAnswerResult2 = q.answers[idx].answerResult2; } @@ -154,7 +146,7 @@ export default { result1: glass.answerData.answerResult, result2: selectedAnswerResult2, answeredQuestions: glass.answerData.answeredQuestions, - isSuppressedPart: glass.isSuppressedPart, + isSuppressedPart: glass.isSuppressedPart }; }); // clear out answerData for future page loads; must occur prior to store save @@ -162,25 +154,21 @@ export default { glass.answerData = {}; }); // save to store as order.damage.moldingQuestionArrays (array) - await this.mainStore.saveCapabilityQuestionAnswers( - questionAnswersArray - ); + await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray); // get parts from the capabilityQuestionAnswers const partsOrQuestions = this.partsOrQuestionsData; // eslint-disable-next-line no-restricted-syntax for (const answer of questionAnswersArray) { - partsOrQuestions.find( - (partOrQuestion) => - partOrQuestion.glassLocation === answer.glassLocation && - partOrQuestion.glassName === answer.glassName - ).parts[0].childParts = [ + partsOrQuestions.find((partOrQuestion) => + partOrQuestion.glassLocation === answer.glassLocation + && partOrQuestion.glassName === answer.glassName).parts[0].childParts = [ { - partNumber: answer.partNum, - }, + partNumber: answer.partNum + } ]; } this.navigateForward(partsOrQuestions, null); - }, - }, + } + } }; diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 75094683..f4eb66fd 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; }, @@ -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; - }, - }, + } + } };