From 98d54e20fdcdb95bfff3256bbf3f5df5905ff0ca Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Fri, 22 Sep 2023 11:39:50 -0500 Subject: [PATCH] SSR-661 Skip VIN Questions if we already have VIN from policy --- src/layouts/vehicle-damage/vehicle-damage.vue | 24 ++++++++++++------- src/layouts/vin-lookup/vin-lookup.vue | 13 ---------- src/mixins/vehicle-questions-mixin.js | 12 ++++++++++ .../router-constants/navigation-scenarios.js | 1 - src/router/router-constants/routing-table.js | 20 ++++++++++++++-- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 4a53e854..02e00a05 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -84,6 +84,7 @@ import alert from '@/ux-components/alert/alert.vue'; // Supporting files import BaseFormMixin from '@/mixins/base-form-mixin.js'; +import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import settleAllPromises from '@/helpers/layout-helper'; import { Form, defineRule } from 'vee-validate'; @@ -112,7 +113,7 @@ export default { Form, alert }, - mixins: [BaseFormMixin], + mixins: [BaseFormMixin, vehicleQuestionsMixin], async beforeRouteEnter(to, from, next) { const store = useMainStore(); @@ -375,10 +376,6 @@ export default { this.mainStore.saveSupportingItems(supportingItems.data); } - return this.navigateForward(); - }, - - navigateForward() { if (this.mainStore.damage.isRepair) { this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, @@ -386,16 +383,25 @@ export default { ); } else if (this.mainStore.order.vehicle.vin) { // If vin already exists, navigate directly to vin-lookup - this.$router.navigate( - this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, - this.$route - ); + + const partsOrQuestionsResponse = await this.getPartsOrQuestions(); + if (partsOrQuestionsResponse.error) { + // To Do: Need requirement on what to do here + window.console.error('Error on retrieving PartsOrQuestions'); + this.$refs.siteFooter.removeLoader(); + return null; + } + + // Comes from vehicleQuestionsMixin.navigateForward() + await this.navigateForward(partsOrQuestionsResponse.data.partsOrQuestions, this); } else { this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.$route ); } + + return null; }, selectedGlassToReplace() { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 67bd391f..d9be15f1 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -241,19 +241,6 @@ export default { return null; }, - async getPartsOrQuestions() { - try { - const response = await this.mainStore.getPartsOrQuestions(); - - return response; - } catch (responseError) { - return { - error: { - status: responseError.status - } - }; - } - }, async lookupVehicleByVin(vin) { try { return await this.mainStore.lookupVehicleByVin(vin); diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 7167dd5a..0ddac0cf 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -341,6 +341,18 @@ export default { } }, + async getPartsOrQuestions() { + try { + return await useMainStore().getPartsOrQuestions(); + } catch (responseError) { + return { + error: { + status: responseError.status + } + }; + } + }, + // Can't use `this` because navigateForward is also called from vin-pages-mixin async navigateForward(partsOrQuestions, vm) { const self = vm ?? this; diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 806d08aa..bb067255 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -33,7 +33,6 @@ const navigationScenarios = Object.freeze({ // Vin selection CLICKED_BACK_WITH_VIN: 'CLICKED_BACK_WITH_VIN', - CLICKED_FORWARD_WITH_VIN: 'CLICKED_FORWARD_WITH_VIN', CLICKED_FORWARD_WITHOUT_VIN: 'CLICKED_FORWARD_WITHOUT_VIN', CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES: 'CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES', SELECTED_VIN_WITH_MISMATCHED_GLASS: 'SELECTED_VIN_WITH_MISMATCHED_GLASS', diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 62d235ae..0b40e00b 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -29,8 +29,24 @@ const routingTable = () => [ destinationIssPageValue: issPageValues.COVERAGE_STATEMENT }, { - scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN, - destinationIssPageValue: issPageValues.VEHICLE_LOOKUP + scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, + destinationIssPageValue: issPageValues.PART_QUESTIONS + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE, + destinationIssPageValue: issPageValues.VEHICLE_PARTS + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS, + destinationIssPageValue: issPageValues.MOLDING_QUESTIONS + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS, + destinationIssPageValue: issPageValues.CAPABILITY_QUESTIONS + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, + destinationIssPageValue: issPageValues.COVERAGE_STATEMENT }, { scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,