SSR-661 Skip VIN Questions if we already have VIN from policy

This commit is contained in:
Josh Dassinger 2023-09-22 11:39:50 -05:00
parent ab06f590ab
commit 98d54e20fd
5 changed files with 45 additions and 25 deletions

View file

@ -84,6 +84,7 @@ import alert from '@/ux-components/alert/alert.vue';
// Supporting files // Supporting files
import BaseFormMixin from '@/mixins/base-form-mixin.js'; import BaseFormMixin from '@/mixins/base-form-mixin.js';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import settleAllPromises from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form, defineRule } from 'vee-validate'; import { Form, defineRule } from 'vee-validate';
@ -112,7 +113,7 @@ export default {
Form, Form,
alert alert
}, },
mixins: [BaseFormMixin], mixins: [BaseFormMixin, vehicleQuestionsMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
const store = useMainStore(); const store = useMainStore();
@ -375,10 +376,6 @@ export default {
this.mainStore.saveSupportingItems(supportingItems.data); this.mainStore.saveSupportingItems(supportingItems.data);
} }
return this.navigateForward();
},
navigateForward() {
if (this.mainStore.damage.isRepair) { if (this.mainStore.damage.isRepair) {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, this.navigationScenarios.CLICKED_FORWARD_WITH_REPAIR,
@ -386,16 +383,25 @@ export default {
); );
} else if (this.mainStore.order.vehicle.vin) { } else if (this.mainStore.order.vehicle.vin) {
// If vin already exists, navigate directly to vin-lookup // If vin already exists, navigate directly to vin-lookup
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN, const partsOrQuestionsResponse = await this.getPartsOrQuestions();
this.$route 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 { } else {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
this.$route this.$route
); );
} }
return null;
}, },
selectedGlassToReplace() { selectedGlassToReplace() {

View file

@ -241,19 +241,6 @@ export default {
return null; return null;
}, },
async getPartsOrQuestions() {
try {
const response = await this.mainStore.getPartsOrQuestions();
return response;
} catch (responseError) {
return {
error: {
status: responseError.status
}
};
}
},
async lookupVehicleByVin(vin) { async lookupVehicleByVin(vin) {
try { try {
return await this.mainStore.lookupVehicleByVin(vin); return await this.mainStore.lookupVehicleByVin(vin);

View file

@ -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 // Can't use `this` because navigateForward is also called from vin-pages-mixin
async navigateForward(partsOrQuestions, vm) { async navigateForward(partsOrQuestions, vm) {
const self = vm ?? this; const self = vm ?? this;

View file

@ -33,7 +33,6 @@ const navigationScenarios = Object.freeze({
// Vin selection // Vin selection
CLICKED_BACK_WITH_VIN: 'CLICKED_BACK_WITH_VIN', 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_WITHOUT_VIN: 'CLICKED_FORWARD_WITHOUT_VIN',
CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES: 'CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES', CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES: 'CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES',
SELECTED_VIN_WITH_MISMATCHED_GLASS: 'SELECTED_VIN_WITH_MISMATCHED_GLASS', SELECTED_VIN_WITH_MISMATCHED_GLASS: 'SELECTED_VIN_WITH_MISMATCHED_GLASS',

View file

@ -29,8 +29,24 @@ const routingTable = () => [
destinationIssPageValue: issPageValues.COVERAGE_STATEMENT destinationIssPageValue: issPageValues.COVERAGE_STATEMENT
}, },
{ {
scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN, scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
destinationIssPageValue: issPageValues.VEHICLE_LOOKUP 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, scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,