Merge pull request #392 from Safelite/feature/CSR-7
Fixed weird formatting / duplicates and added QA var's
This commit is contained in:
commit
ae3fbf1c91
2 changed files with 306 additions and 360 deletions
|
|
@ -121,4 +121,7 @@ stages:
|
||||||
__VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__)
|
__VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__)
|
||||||
__VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__)
|
__VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__)
|
||||||
__VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__)
|
__VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__)
|
||||||
|
indexDeployVariables:
|
||||||
|
__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__)
|
||||||
|
__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__)
|
||||||
cfDistributionId: $(cfDistributionId)
|
cfDistributionId: $(cfDistributionId)
|
||||||
|
|
@ -1,106 +1,35 @@
|
||||||
<template>
|
<template>
|
||||||
<Form
|
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
||||||
@submit="onSubmit"
|
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||||
@invalid-submit="onInvalidSubmit"
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||||
ref="theForm"
|
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="false" />
|
||||||
v-slot="{ meta }"
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||||
>
|
<div class="row my-2">
|
||||||
<div
|
<div class="col">
|
||||||
class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5"
|
<textboxQuestion cmsWidgetName="LicensePlateNumber" v-model="licensePlate" isRequired inputId="license_plate" validationRules="license-plate-required" />
|
||||||
>
|
</div>
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
|
||||||
<vehicleBanner
|
|
||||||
cmsWidgetName="VehicleBannerWidget"
|
|
||||||
:displayGenericVehicleImage="false"
|
|
||||||
/>
|
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
|
||||||
<div class="row my-2">
|
|
||||||
<div class="col">
|
|
||||||
<textboxQuestion
|
|
||||||
cmsWidgetName="LicensePlateNumber"
|
|
||||||
v-model="licensePlate"
|
|
||||||
isRequired
|
|
||||||
inputId="license_plate"
|
|
||||||
validationRules="license-plate-required"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row my-2">
|
||||||
<div class="row my-2">
|
<div class="col">
|
||||||
<div class="col">
|
<textboxQuestion cmsWidgetName="RegistrationZip" v-model="registrationZip" inputId="zip" mask="#####" validationRules="zip-required" />
|
||||||
<textboxQuestion
|
</div>
|
||||||
cmsWidgetName="RegistrationZip"
|
|
||||||
v-model="registrationZip"
|
|
||||||
inputId="zip"
|
|
||||||
mask="#####"
|
|
||||||
validationRules="zip-required"
|
|
||||||
/>
|
|
||||||
<textboxQuestion
|
|
||||||
cmsWidgetName="RegistrationZip"
|
|
||||||
v-model="registrationZip"
|
|
||||||
isRequired
|
|
||||||
inputId="zip"
|
|
||||||
mask="#####"
|
|
||||||
validationRules="zip-required"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row my-2">
|
||||||
<div class="row my-2">
|
<div class="col">
|
||||||
<div class="col">
|
<textboxQuestion cmsWidgetName="EmailAddress" v-model="email" inputId="email" validationRules="email-address-required|email-address-format" />
|
||||||
<textboxQuestion
|
</div>
|
||||||
cmsWidgetName="EmailAddress"
|
|
||||||
v-model="email"
|
|
||||||
inputId="email"
|
|
||||||
validationRules="email-address-required|email-address-format"
|
|
||||||
/>
|
|
||||||
<textboxQuestion
|
|
||||||
cmsWidgetName="EmailAddress"
|
|
||||||
v-model="email"
|
|
||||||
isRequired
|
|
||||||
inputId="email"
|
|
||||||
validationRules="email-address-required|email-address-format"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<alert class="my-3" :manualHeadline="NoServiceZipHeader" :manualCopy="NoServiceZipBody" v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent" alertClass="alert-danger" />
|
||||||
<alert
|
<div class="row my-2">
|
||||||
class="my-3"
|
<div class="col">
|
||||||
:manualHeadline="NoServiceZipHeader"
|
<textboxQuestion v-if="!isRegistrationZipServicable" cmsWidgetName="ServiceZip" v-model="serviceZip" inputId="serviceZip" validationRules="zip-required" />
|
||||||
:manualCopy="NoServiceZipBody"
|
</div>
|
||||||
v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent"
|
|
||||||
alertClass="alert-danger"
|
|
||||||
/>
|
|
||||||
<div class="row my-2">
|
|
||||||
<div class="col">
|
|
||||||
<textboxQuestion
|
|
||||||
v-if="!isRegistrationZipServicable"
|
|
||||||
cmsWidgetName="ServiceZip"
|
|
||||||
v-model="serviceZip"
|
|
||||||
inputId="serviceZip"
|
|
||||||
validationRules="zip-required"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<alert class="my-3" cmsWidgetName="NoMatchAlertWidget" v-if="!isVinValid" alertClass="alert-danger" />
|
||||||
<alert
|
<alert class="my-3" :manualHeadline="MatchedDifferentVehicleAlertHeader" :manualCopy="MatchedDifferentVehicleAlertBody" v-if="isCarIdDifferent" alertClass="alert-warning" />
|
||||||
class="my-3"
|
<funnelFooter ref="funnelFooter" cmsWidgetName="FunnelFooterWidget" :isForwardActionDisabled="!meta.valid" @back-clicked="backButtonAction" @ForwardClicked="forwardButtonAction" />
|
||||||
cmsWidgetName="NoMatchAlertWidget"
|
|
||||||
v-if="!isVinValid"
|
|
||||||
alertClass="alert-danger"
|
|
||||||
/>
|
|
||||||
<alert
|
|
||||||
class="my-3"
|
|
||||||
:manualHeadline="MatchedDifferentVehicleAlertHeader"
|
|
||||||
:manualCopy="MatchedDifferentVehicleAlertBody"
|
|
||||||
v-if="isCarIdDifferent"
|
|
||||||
alertClass="alert-warning"
|
|
||||||
/>
|
|
||||||
<funnelFooter
|
|
||||||
ref="funnelFooter"
|
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
|
||||||
:isForwardActionDisabled="!meta.valid"
|
|
||||||
@back-clicked="backButtonAction"
|
|
||||||
@ForwardClicked="forwardButtonAction"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -113,292 +42,306 @@ import alert from "@/ux-components/alert/alert";
|
||||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import {
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
fetchCmsContentForPage
|
||||||
|
} from "@/helpers/cms-content-helper";
|
||||||
|
import {
|
||||||
|
settleAllPromises
|
||||||
|
} from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
|
||||||
import {
|
import {
|
||||||
getDamageString,
|
storeActions
|
||||||
isGlassAvailableForCarId,
|
} from "@/constants/store-actions";
|
||||||
|
import {
|
||||||
|
storeMutations
|
||||||
|
} from "@/constants/store-mutations";
|
||||||
|
import {
|
||||||
|
errorMessages
|
||||||
|
} from "@/constants/error-messages";
|
||||||
|
import {
|
||||||
|
getDamageString,
|
||||||
|
isGlassAvailableForCarId,
|
||||||
} from "@/helpers/damage-helper";
|
} from "@/helpers/damage-helper";
|
||||||
import { required, regex } from "@/helpers/validation-rules";
|
import {
|
||||||
import { Form, defineRule } from "vee-validate";
|
required,
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
regex
|
||||||
|
} from "@/helpers/validation-rules";
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
defineRule
|
||||||
|
} from "vee-validate";
|
||||||
|
import {
|
||||||
|
navigateAfterSaveToHeritageFunnel
|
||||||
|
} from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule(
|
defineRule(
|
||||||
"license-plate-required",
|
"license-plate-required",
|
||||||
required(errorMessages.LICENSE_PLATE_REQUIRED)
|
required(errorMessages.LICENSE_PLATE_REQUIRED)
|
||||||
);
|
);
|
||||||
defineRule("zip-required", required(errorMessages.ZIP_REQUIRED));
|
defineRule("zip-required", required(errorMessages.ZIP_REQUIRED));
|
||||||
defineRule(
|
defineRule(
|
||||||
"email-address-required",
|
"email-address-required",
|
||||||
required(errorMessages.EMAIL_ADDRESS_REQUIRED)
|
required(errorMessages.EMAIL_ADDRESS_REQUIRED)
|
||||||
);
|
);
|
||||||
defineRule(
|
defineRule(
|
||||||
"email-address-format",
|
"email-address-format",
|
||||||
regex(
|
regex(
|
||||||
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+).([a-zA-Z]{2,})$/,
|
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+).([a-zA-Z]{2,})$/,
|
||||||
errorMessages.EMAIL_ADDRESS_FORMAT
|
errorMessages.EMAIL_ADDRESS_FORMAT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "license-plate-lookup",
|
name: "license-plate-lookup",
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [{
|
||||||
{
|
resultKey: "cmsContent",
|
||||||
resultKey: "cmsContent",
|
promise: cmsContentPromise,
|
||||||
promise: cmsContentPromise,
|
}, ];
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
validationRules: String,
|
validationRules: String,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isRegistrationZipServicable: true,
|
isRegistrationZipServicable: true,
|
||||||
isVinValid: true,
|
isVinValid: true,
|
||||||
isCarIdDifferent: false,
|
isCarIdDifferent: false,
|
||||||
licensePlate: this.getLicensePlateFromStore(),
|
licensePlate: this.getLicensePlateFromStore(),
|
||||||
registrationZip: this.getRegistrationZipFromStore(),
|
registrationZip: this.getRegistrationZipFromStore(),
|
||||||
email: this.getEmailFromStore(),
|
email: this.getEmailFromStore(),
|
||||||
serviceZip: this.getServiceZipFromStore(),
|
serviceZip: this.getServiceZipFromStore(),
|
||||||
previouslyEnteredCarId: "",
|
previouslyEnteredCarId: "",
|
||||||
customAlertData: {},
|
customAlertData: {},
|
||||||
isSelectedGlassAvailableForVehicle: true,
|
isSelectedGlassAvailableForVehicle: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.attachCustomEvents();
|
this.attachCustomEvents();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
MatchedDifferentVehicleAlertHeader() {
|
MatchedDifferentVehicleAlertHeader() {
|
||||||
let text = this.getCmsContent(
|
let text = this.getCmsContent(
|
||||||
"MatchedDifferentVehicleAlertWidget",
|
"MatchedDifferentVehicleAlertWidget",
|
||||||
"HeadlineText"
|
"HeadlineText"
|
||||||
).replaceAll("{custom:damage}", getDamageString());
|
).replaceAll("{custom:damage}", getDamageString());
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
MatchedDifferentVehicleAlertBody() {
|
MatchedDifferentVehicleAlertBody() {
|
||||||
let text = this.getCmsContent(
|
let text = this.getCmsContent(
|
||||||
"MatchedDifferentVehicleAlertWidget",
|
"MatchedDifferentVehicleAlertWidget",
|
||||||
"BodyText"
|
"BodyText"
|
||||||
)
|
)
|
||||||
.replaceAll("{custom:damage}", getDamageString())
|
.replaceAll("{custom:damage}", getDamageString())
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"{custom:plateLookupYear}",
|
"{custom:plateLookupYear}",
|
||||||
this.customAlertData?.vehicleInfo?.year
|
this.customAlertData?.vehicleInfo?.year
|
||||||
)
|
)
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"{custom:plateLookupMake}",
|
"{custom:plateLookupMake}",
|
||||||
this.customAlertData?.vehicleInfo?.make
|
this.customAlertData?.vehicleInfo?.make
|
||||||
)
|
)
|
||||||
.replaceAll(
|
.replaceAll(
|
||||||
"{custom:plateLookupModel}",
|
"{custom:plateLookupModel}",
|
||||||
this.customAlertData?.vehicleInfo?.model
|
this.customAlertData?.vehicleInfo?.model
|
||||||
);
|
);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
NoServiceZipHeader() {
|
NoServiceZipHeader() {
|
||||||
let text = this.getCmsContent(
|
let text = this.getCmsContent(
|
||||||
"NoServiceZipWidget",
|
"NoServiceZipWidget",
|
||||||
"HeadlineText"
|
"HeadlineText"
|
||||||
).replaceAll("{custom:zip}", this.registrationZip);
|
).replaceAll("{custom:zip}", this.registrationZip);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
NoServiceZipBody() {
|
NoServiceZipBody() {
|
||||||
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
arePagePrerequisitesValid() {
|
|
||||||
return store.getters.vehicle.carId !== null;
|
|
||||||
},
|
|
||||||
resetDependentState() {
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
|
||||||
},
|
|
||||||
attachCustomEvents() {
|
|
||||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
|
||||||
this.pushEventToGA(
|
|
||||||
this.$route.query[this.queryStrings.FMG_PAGE],
|
|
||||||
this.GaActions.SUBMITTED,
|
|
||||||
this.GaLabels.LICENSE_PLATE_LOOKUP,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getLicensePlateFromStore() {
|
|
||||||
return store.getters.vehicle.registration.licensePlate;
|
|
||||||
},
|
|
||||||
getRegistrationZipFromStore() {
|
|
||||||
return store.getters.vehicle.registration.zipCode;
|
|
||||||
},
|
|
||||||
getEmailFromStore() {
|
|
||||||
return store.getters.order.customer.emailAddress;
|
|
||||||
},
|
|
||||||
getServiceZipFromStore(){
|
|
||||||
return store.getters.order.serviceLocation.zipCode
|
|
||||||
},
|
|
||||||
backButtonAction() {
|
|
||||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
|
||||||
},
|
|
||||||
async forwardButtonAction() {
|
|
||||||
const zipValidation = this.serviceZip
|
|
||||||
? await this.validateZip(this.serviceZip)
|
|
||||||
: await this.validateZip(this.registrationZip);
|
|
||||||
if (!zipValidation.data.isServiceable) {
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
this.isVinValid = true;
|
|
||||||
this.isRegistrationZipServicable = false;
|
|
||||||
this.isCarIdDifferent = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const vinLookup = await this.lookupVin(
|
|
||||||
this.licensePlate,
|
|
||||||
zipValidation.data.state
|
|
||||||
).catch(() => {
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
this.isVinValid = false;
|
|
||||||
this.isCarIdDifferent = false;
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.isCarIdDifferent =
|
|
||||||
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
|
||||||
|
|
||||||
if (
|
|
||||||
this.isCarIdDifferent &&
|
|
||||||
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
|
|
||||||
) {
|
|
||||||
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
|
||||||
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
|
|
||||||
this.$refs.funnelFooter.updateButtonText(
|
|
||||||
`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`
|
|
||||||
);
|
|
||||||
this.isVinValid = true;
|
|
||||||
this.isSelectedGlassAvailableForVehicle =
|
|
||||||
await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateCustomerInfo(
|
|
||||||
vinLookup.data.vin,
|
|
||||||
vinLookup.data.vehicle,
|
|
||||||
zipValidation.data.state
|
|
||||||
);
|
|
||||||
|
|
||||||
const partsData = await baseMixin.methods.dispatchStoreAction(
|
|
||||||
this.storeActions.GET_PARTS_OR_QUESTIONS,
|
|
||||||
{
|
|
||||||
carId: vinLookup.data.vehicle.carId,
|
|
||||||
glassArray:
|
|
||||||
this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle
|
|
||||||
? []
|
|
||||||
: store.getters.damage.glassToReplace,
|
|
||||||
zipCode: this.serviceZip ? this.serviceZip : this.registrationZip,
|
|
||||||
vin: vinLookup.data.vin,
|
|
||||||
},
|
},
|
||||||
false
|
|
||||||
);
|
|
||||||
this.navigateForward(partsData);
|
|
||||||
},
|
},
|
||||||
navigateForward(partsData) {
|
methods: {
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
arePagePrerequisitesValid() {
|
||||||
this.$router.navigateAfterSave(
|
return store.getters.vehicle.carId !== null;
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
},
|
||||||
this.$route,
|
resetDependentState() {
|
||||||
{},
|
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||||
{ displayVehicleChangeAlert: true },
|
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||||
partsData.data
|
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||||
);
|
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||||
return;
|
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||||
} else {
|
},
|
||||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
attachCustomEvents() {
|
||||||
return;
|
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||||
}
|
this.pushEventToGA(
|
||||||
|
this.$route.query[this.queryStrings.FMG_PAGE],
|
||||||
|
this.GaActions.SUBMITTED,
|
||||||
|
this.GaLabels.LICENSE_PLATE_LOOKUP,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getLicensePlateFromStore() {
|
||||||
|
return store.getters.vehicle.registration.licensePlate;
|
||||||
|
},
|
||||||
|
getRegistrationZipFromStore() {
|
||||||
|
return store.getters.vehicle.registration.zipCode;
|
||||||
|
},
|
||||||
|
getEmailFromStore() {
|
||||||
|
return store.getters.order.customer.emailAddress;
|
||||||
|
},
|
||||||
|
getServiceZipFromStore() {
|
||||||
|
return store.getters.order.serviceLocation.zipCode
|
||||||
|
},
|
||||||
|
backButtonAction() {
|
||||||
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
|
},
|
||||||
|
async forwardButtonAction() {
|
||||||
|
const zipValidation = this.serviceZip ?
|
||||||
|
await this.validateZip(this.serviceZip) :
|
||||||
|
await this.validateZip(this.registrationZip);
|
||||||
|
if (!zipValidation.data.isServiceable) {
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
|
this.isVinValid = true;
|
||||||
|
this.isRegistrationZipServicable = false;
|
||||||
|
this.isCarIdDifferent = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vinLookup = await this.lookupVin(
|
||||||
|
this.licensePlate,
|
||||||
|
zipValidation.data.state
|
||||||
|
).catch(() => {
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
|
this.isVinValid = false;
|
||||||
|
this.isCarIdDifferent = false;
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.isCarIdDifferent =
|
||||||
|
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.isCarIdDifferent &&
|
||||||
|
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
|
||||||
|
) {
|
||||||
|
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
||||||
|
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
|
||||||
|
this.$refs.funnelFooter.updateButtonText(
|
||||||
|
`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`
|
||||||
|
);
|
||||||
|
this.isVinValid = true;
|
||||||
|
this.isSelectedGlassAvailableForVehicle =
|
||||||
|
await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateCustomerInfo(
|
||||||
|
vinLookup.data.vin,
|
||||||
|
vinLookup.data.vehicle,
|
||||||
|
zipValidation.data.state
|
||||||
|
);
|
||||||
|
|
||||||
|
const partsData = await baseMixin.methods.dispatchStoreAction(
|
||||||
|
this.storeActions.GET_PARTS_OR_QUESTIONS, {
|
||||||
|
carId: vinLookup.data.vehicle.carId,
|
||||||
|
glassArray: this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle ? [] : store.getters.damage.glassToReplace,
|
||||||
|
zipCode: this.serviceZip ? this.serviceZip : this.registrationZip,
|
||||||
|
vin: vinLookup.data.vin,
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
this.navigateForward(partsData);
|
||||||
|
},
|
||||||
|
navigateForward(partsData) {
|
||||||
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
|
this.$router.navigateAfterSave(
|
||||||
|
this.navigationScenarios.CLICKED_FORWARD,
|
||||||
|
this.$route, {}, {
|
||||||
|
displayVehicleChangeAlert: true
|
||||||
|
},
|
||||||
|
partsData.data
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
validateZip(zip) {
|
||||||
|
return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
||||||
|
zip,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
lookupVin(plate, state) {
|
||||||
|
return baseMixin.methods.dispatchStoreAction(
|
||||||
|
storeActions.LOOKUP_VIN_BY_PLATE, {
|
||||||
|
licensePlate: plate,
|
||||||
|
licenseState: state
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
updateCustomerInfo(vin, vehicleInfo, registrationState) {
|
||||||
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
|
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
|
}
|
||||||
|
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
||||||
|
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, vehicleInfo.make);
|
||||||
|
store.commit(storeMutations.UPDATE_MODEL, vehicleInfo.model);
|
||||||
|
store.commit(storeMutations.UPDATE_STYLE, vehicleInfo.style);
|
||||||
|
store.commit(storeMutations.UPDATE_CAR_ID, vehicleInfo.carId);
|
||||||
|
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, vehicleInfo.category);
|
||||||
|
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, vehicleInfo.imageUrl);
|
||||||
|
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, vehicleInfo.imageVifNumber);
|
||||||
|
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, vehicleInfo.imageColor);
|
||||||
|
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, this.licensePlate);
|
||||||
|
store.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationState);
|
||||||
|
store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip);
|
||||||
|
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZip);
|
||||||
|
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
validateZip(zip) {
|
watch: {
|
||||||
return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
licensePlate() {
|
||||||
zip,
|
this.$refs.funnelFooter.updateButtonText(
|
||||||
});
|
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
registrationZip() {
|
||||||
|
this.$refs.funnelFooter.updateButtonText(
|
||||||
|
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
serviceZip() {
|
||||||
|
this.$refs.funnelFooter.updateButtonText(
|
||||||
|
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
lookupVin(plate, state) {
|
components: {
|
||||||
return baseMixin.methods.dispatchStoreAction(
|
Form,
|
||||||
storeActions.LOOKUP_VIN_BY_PLATE,
|
funnelHeader,
|
||||||
{ licensePlate: plate, licenseState: state }
|
vehicleBanner,
|
||||||
);
|
funnelSubHeader,
|
||||||
|
textboxQuestion,
|
||||||
|
alert,
|
||||||
|
funnelFooter,
|
||||||
},
|
},
|
||||||
updateCustomerInfo(vin, vehicleInfo, registrationState) {
|
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
|
||||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
|
||||||
}
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
|
||||||
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, vehicleInfo.make);
|
|
||||||
store.commit(storeMutations.UPDATE_MODEL, vehicleInfo.model);
|
|
||||||
store.commit(storeMutations.UPDATE_STYLE, vehicleInfo.style);
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, vehicleInfo.carId);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY,vehicleInfo.category);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL,vehicleInfo.imageUrl);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER,vehicleInfo.imageVifNumber);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR,vehicleInfo.imageColor);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE,this.licensePlate);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationState);
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip);
|
|
||||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZip);
|
|
||||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
licensePlate() {
|
|
||||||
this.$refs.funnelFooter.updateButtonText(
|
|
||||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
registrationZip() {
|
|
||||||
this.$refs.funnelFooter.updateButtonText(
|
|
||||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
serviceZip() {
|
|
||||||
this.$refs.funnelFooter.updateButtonText(
|
|
||||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
Form,
|
|
||||||
funnelHeader,
|
|
||||||
vehicleBanner,
|
|
||||||
funnelSubHeader,
|
|
||||||
textboxQuestion,
|
|
||||||
alert,
|
|
||||||
funnelFooter,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue