navigation from license-plate-lookup
This commit is contained in:
parent
49db6154b7
commit
775f461170
1 changed files with 26 additions and 12 deletions
|
|
@ -50,6 +50,8 @@ import { useMainStore } from '@/store';
|
|||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { required, regex } from "@/helpers/validation-rules";
|
||||
import { defineRule } from "vee-validate";
|
||||
import { isGlassAvailableForCarId } from '@/helpers/damage-helper.js';
|
||||
import { routerParams } from '@/router/router-params.js'
|
||||
|
||||
// Import Component
|
||||
import baseFormMixin from '@/mixins/base-form-mixin';
|
||||
|
|
@ -77,6 +79,7 @@ export default {
|
|||
vehicleBanner,
|
||||
textboxQuestion,
|
||||
licensePlateLookupAlerts,
|
||||
isGlassAvailableForCarId
|
||||
},
|
||||
setup() {
|
||||
const mainStore = useMainStore();
|
||||
|
|
@ -86,10 +89,10 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
activeVehicleLookupAlertType: null,
|
||||
needToLookupVehicle: true,
|
||||
vehicleFromLookup: null,
|
||||
licensePlate: null,
|
||||
registrationZipCode: null,
|
||||
isCarIdDifferent: false,
|
||||
};
|
||||
},
|
||||
provide() {
|
||||
|
|
@ -114,6 +117,14 @@ export default {
|
|||
vm.setCmsContent(resultMap.cmsContent);
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
isCarIdDifferentFromTheStore() {
|
||||
return (
|
||||
this.vehicleFromLookup !== null
|
||||
&& this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId
|
||||
);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
if (this.mainStore.order.vehicle.carId) {
|
||||
|
|
@ -127,33 +138,33 @@ export default {
|
|||
*/
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
},
|
||||
// NOTE: If form is not valid, this method is not called when 'Continue' button is clicked
|
||||
async forwardButtonAction() {
|
||||
this.resetActiveAlert();
|
||||
|
||||
// NOTE: If form is not valid, this method is not called when 'Continue' button is clicked
|
||||
if (this.needToLookupVehicle) {
|
||||
const vehicleLookupResponse = await this.mainStore.lookupVinByPlate(this.licensePlate);
|
||||
|
||||
|
||||
if (vehicleLookupResponse.error) {
|
||||
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
|
||||
this.resetVehicleFromLookup();
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
this.vehicleFromLookup = vehicleLookupResponse.data.vehicle;
|
||||
if (this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId) {
|
||||
|
||||
if (this.needToLookupVehicle && this.isCarIdDifferentFromTheStore) {
|
||||
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_MATCHED;
|
||||
this.isCarIdDifferent = true;
|
||||
const vehicleYearMakeModel = `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model}`;
|
||||
|
||||
this.$refs.siteFooter.updateButtonText(`Continue with ${vehicleYearMakeModel}`);
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
|
||||
this.needToLookupVehicle = false;
|
||||
}
|
||||
|
||||
// Continue
|
||||
},
|
||||
async navigateForward() {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
if (this.isCarIdDifferentFromTheStore && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route,
|
||||
|
|
@ -161,10 +172,13 @@ export default {
|
|||
{ [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true }
|
||||
);
|
||||
} else {
|
||||
await this.navigateForwardWithSingleCarMatch();
|
||||
await this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
|
||||
this.$route
|
||||
);
|
||||
}
|
||||
// Continue
|
||||
},
|
||||
|
||||
resetActiveAlert() {
|
||||
this.activeVehicleLookupAlertType = null;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue