Init refactor
This commit is contained in:
parent
1fae6c5bde
commit
3226ec4e6e
12 changed files with 406 additions and 342 deletions
|
|
@ -24,6 +24,7 @@ const storeActions = {
|
|||
INITIALIZE_SESSION: "initializeSession",
|
||||
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
|
||||
UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration",
|
||||
UPDATE_VEHICLE_INFO: 'updateVehicleInfo',
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ const storeMutations = {
|
|||
UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber",
|
||||
UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor",
|
||||
UPDATE_VEHICLE_VIN: "updateVehicleVin",
|
||||
UPDATE_VEHICLE: "updateVehicle",
|
||||
|
||||
UPDATE_IS_REPAIR: "updateIsRepair",
|
||||
UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips",
|
||||
UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace",
|
||||
UPDATE_GLASS_PARTS: "updateGlassParts",
|
||||
|
||||
UPDATE_REGISTRATION_LICENSE_PLATE : "updateRegistrationLicensePlate",
|
||||
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
|
||||
UPDATE_REGISTRATION_CITY: "updateRegistrationCity",
|
||||
|
|
@ -22,8 +25,12 @@ const storeMutations = {
|
|||
UPDATE_REGISTRATION_ZIP_CODE: "updateRegistrationZipCode",
|
||||
UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName",
|
||||
UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName",
|
||||
UPDATE_REGISTRATION: "updateRegistration",
|
||||
|
||||
UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode",
|
||||
UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState",
|
||||
UPDATE_SERVICE_LOCATION: "updateServiceLocation",
|
||||
|
||||
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
|
||||
|
||||
// ORDER MUTATIONS
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ export default {
|
|||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route,
|
||||
{},
|
||||
{},
|
||||
{ displayVehicleChangeAlert: true },
|
||||
);
|
||||
return;
|
||||
|
|
@ -198,10 +198,7 @@ export default {
|
|||
{ vin }
|
||||
);
|
||||
},
|
||||
resetDependentState() { // needed because navigateAfterSaveToHeritageFunnel calls it
|
||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||
},
|
||||
//this.$store.dispatch(storeActions.SAVE_VIN, vin,vehicle),
|
||||
//this.dispatchStoreAction(storeActions.SAVE_VIN, vin,vehicle),
|
||||
updateCustomerInfo(vin, vehicle) {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.dispatchStoreAction(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
<template>
|
||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
||||
<Form
|
||||
@submit="onSubmit"
|
||||
@invalid-submit="onInvalidSubmit"
|
||||
ref="theForm"
|
||||
v-slot="{ meta }"
|
||||
>
|
||||
<div class="page-container-grouped-styles">
|
||||
<loadingModal ref="loadingModal"/>
|
||||
<loadingModal ref="loadingModal" />
|
||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="false" />
|
||||
<vehicleBanner
|
||||
cmsWidgetName="VehicleBannerWidget"
|
||||
:displayGenericVehicleImage="false"
|
||||
/>
|
||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||
<div class="fade-on-route-transition sub-container make-tall">
|
||||
<div class="row my-2">
|
||||
|
|
@ -56,11 +64,14 @@
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<alert class="my-3"
|
||||
cmsWidgetName="NoMatchAlertWidget"
|
||||
<alert
|
||||
class="my-3"
|
||||
cmsWidgetName="NoMatchAlertWidget"
|
||||
v-if="!isVinValid"
|
||||
alertClass="alert-warning" />
|
||||
<alert class="my-3"
|
||||
alertClass="alert-warning"
|
||||
/>
|
||||
<alert
|
||||
class="my-3"
|
||||
:manualHeadline="MatchedDifferentVehicleAlertHeader"
|
||||
:manualCopy="MatchedDifferentVehicleAlertBody"
|
||||
v-if="isCarIdDifferent"
|
||||
|
|
@ -78,7 +89,6 @@
|
|||
</Form>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
// Components
|
||||
import funnelHeader from "@/common-components/funnel-header/funnel-header";
|
||||
|
|
@ -87,7 +97,7 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
|||
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
||||
import alert from "@/ux-components/alert/alert";
|
||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||
import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
|
||||
// Supporting files
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
|
|
@ -95,17 +105,35 @@ import store from "@/store";
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { getDamageString, isGlassAvailableForCarId, } from "@/helpers/damage-helper";
|
||||
import { required, regex, } from "@/helpers/validation-rules";
|
||||
import { Form, defineRule, } from "vee-validate";
|
||||
import {
|
||||
getDamageString,
|
||||
isGlassAvailableForCarId,
|
||||
} from "@/helpers/damage-helper";
|
||||
import { required, regex } from "@/helpers/validation-rules";
|
||||
import { Form, defineRule } from "vee-validate";
|
||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule("license-plate-required", required(errorMessages.LICENSE_PLATE_REQUIRED));
|
||||
defineRule(
|
||||
"license-plate-required",
|
||||
required(errorMessages.LICENSE_PLATE_REQUIRED)
|
||||
);
|
||||
defineRule("zip-required", required(errorMessages.REGISTRATION_ZIP_REQUIRED));
|
||||
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT));
|
||||
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED));
|
||||
defineRule("email-address-format", regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/, errorMessages.EMAIL_ADDRESS_FORMAT));
|
||||
defineRule(
|
||||
"zip-format",
|
||||
regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT)
|
||||
);
|
||||
defineRule(
|
||||
"email-address-required",
|
||||
required(errorMessages.EMAIL_ADDRESS_REQUIRED)
|
||||
);
|
||||
defineRule(
|
||||
"email-address-format",
|
||||
regex(
|
||||
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/,
|
||||
errorMessages.EMAIL_ADDRESS_FORMAT
|
||||
)
|
||||
);
|
||||
|
||||
export default {
|
||||
name: "license-plate-lookup",
|
||||
|
|
@ -191,21 +219,14 @@ export default {
|
|||
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.pushEventToGA(
|
||||
this.$route.query[this.queryStrings.FMG_PAGE],
|
||||
this.GaActions.SUBMITTED,
|
||||
this.GaLabels.LICENSE_PLATE_LOOKUP,
|
||||
true
|
||||
);
|
||||
);
|
||||
});
|
||||
},
|
||||
getLicensePlateFromStore() {
|
||||
|
|
@ -226,9 +247,10 @@ export default {
|
|||
async forwardButtonAction() {
|
||||
//Call zip validation services
|
||||
const registrationZipValidationPromise = this.validateZip(this.registrationZip);
|
||||
const serviceZipValidationPromise = this.serviceZip ? this.validateZip(this.serviceZip) : null;
|
||||
const registrationZipValidationResults = await registrationZipValidationPromise;
|
||||
const serviceZipValidationResults = serviceZipValidationPromise !== null ? (await serviceZipValidationPromise) : registrationZipValidationResults;
|
||||
|
||||
const serviceZipValidationPromise = this.serviceZip? this.validateZip(this.serviceZip): null;
|
||||
const serviceZipValidationResults = serviceZipValidationPromise !== null ? await serviceZipValidationPromise: registrationZipValidationResults;
|
||||
|
||||
//Handle service zip validations
|
||||
if (!serviceZipValidationResults.data.isServiceable) {
|
||||
|
|
@ -236,11 +258,13 @@ export default {
|
|||
this.isVinValid = true;
|
||||
this.isRegistrationZipServicable = false;
|
||||
this.isCarIdDifferent = false;
|
||||
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip;
|
||||
this.zipToDisplay = this.serviceZip
|
||||
? this.serviceZip
|
||||
: this.registrationZip;
|
||||
return;
|
||||
} else if (!this.serviceZip) {
|
||||
this.serviceZip = this.registrationZip;
|
||||
}
|
||||
} else if (!this.serviceZip) {
|
||||
this.serviceZip = this.registrationZip;
|
||||
}
|
||||
|
||||
//Lookup vin
|
||||
const vinLookup = await this.lookupVin(
|
||||
|
|
@ -252,7 +276,7 @@ export default {
|
|||
this.isCarIdDifferent = false;
|
||||
return;
|
||||
});
|
||||
|
||||
|
||||
this.isCarIdDifferent =
|
||||
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
||||
|
||||
|
|
@ -272,13 +296,13 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
//Save
|
||||
this.updateCustomerInfo(
|
||||
vinLookup.data.vin,
|
||||
vinLookup.data.vehicle,
|
||||
registrationZipValidationResults.data.state,
|
||||
serviceZipValidationResults.data.state
|
||||
);
|
||||
// Save vin and vehicle information
|
||||
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
|
||||
isCarIdDifferent: this.isCarIdDifferent,
|
||||
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
||||
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin})
|
||||
});
|
||||
|
||||
|
||||
//Navigate
|
||||
this.navigateForward();
|
||||
|
|
@ -304,28 +328,11 @@ export default {
|
|||
});
|
||||
},
|
||||
lookupVin(plate, state) {
|
||||
return this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false);
|
||||
},
|
||||
updateCustomerInfo(vin, vehicleInfo, registrationState, serviceState) {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.dispatchStoreAction(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.imageVifColor);
|
||||
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_SERVICE_LOCATION_STATE, serviceState);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
return this.dispatchStoreAction(
|
||||
storeActions.LOOKUP_VIN_BY_PLATE,
|
||||
{ licensePlate: plate, licenseState: state },
|
||||
false
|
||||
);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
|
|
|||
|
|
@ -184,16 +184,16 @@ export default {
|
|||
getDamageLocationsFromStore() {
|
||||
var glassSelections = [];
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD }) ||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD }) ||
|
||||
store.getters.damage.isRepair) {
|
||||
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
||||
}
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER ||
|
||||
glass.location === damageLocationsSelected.PASSENGER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER ||
|
||||
glass.glassLocation === damageLocationsSelected.PASSENGER })) {
|
||||
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.REAR })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.REAR })) {
|
||||
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
||||
}
|
||||
|
||||
|
|
@ -206,20 +206,20 @@ export default {
|
|||
if (store.getters.damage.isRepair === undefined) return windshieldOptions;
|
||||
|
||||
if (!store.getters.damage.isRepair) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.SINGLE })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.SINGLE })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.DRIVER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.DRIVER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.PASSENGER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.PASSENGER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER);
|
||||
}
|
||||
|
|
@ -236,11 +236,11 @@ export default {
|
|||
|
||||
getDoorSidesFromStore() {
|
||||
var doorSides = [];
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER })){
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER })){
|
||||
doorSides.push(damageLocationsSelected.DRIVERSIDE);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.PASSENGER })){
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.PASSENGER })){
|
||||
doorSides.push(damageLocationsSelected.PASSENGERSIDE);
|
||||
}
|
||||
|
||||
|
|
@ -251,8 +251,8 @@ export default {
|
|||
var driverSideReplaceOptions = [];
|
||||
|
||||
store.getters.damage.glassToReplace?.forEach(glass => {
|
||||
if (glass.location === damageLocationsSelected.DRIVER){
|
||||
driverSideReplaceOptions.push(glass.name);
|
||||
if (glass.glassLocation === damageLocationsSelected.DRIVER){
|
||||
driverSideReplaceOptions.push(glass.glassName);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -263,8 +263,8 @@ export default {
|
|||
var passengerSideReplaceOptions = [];
|
||||
|
||||
store.getters.damage.glassToReplace?.forEach(glass => {
|
||||
if (glass.location === damageLocationsSelected.PASSENGER){
|
||||
passengerSideReplaceOptions.push(glass.name);
|
||||
if (glass.glassLocation === damageLocationsSelected.PASSENGER){
|
||||
passengerSideReplaceOptions.push(glass.glassName);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -275,8 +275,8 @@ export default {
|
|||
var rearReplaceOptions = [];
|
||||
|
||||
store.getters.damage.glassToReplace?.forEach(glass => {
|
||||
if (glass.location === damageLocationsSelected.REAR){
|
||||
rearReplaceOptions.push(glass.name);
|
||||
if (glass.glassLocation === damageLocationsSelected.REAR){
|
||||
rearReplaceOptions.push(glass.glassName);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -284,16 +284,13 @@ export default {
|
|||
},
|
||||
|
||||
async forwardButtonAction() {
|
||||
store.commit(this.storeMutations.UPDATE_IS_REPAIR, this.isWindshieldRepair);
|
||||
|
||||
if (this.isWindshieldRepair){
|
||||
store.commit(this.storeMutations.UPDATE_NUMBER_OF_CHIPS, parseInt(this.selectedWindshieldOptions.selectedWindshieldChipCount));
|
||||
} else {
|
||||
store.commit(this.storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
|
||||
}
|
||||
|
||||
store.commit(this.storeMutations.UPDATE_GLASS_TO_REPLACE, this.selectedGlassToReplace());
|
||||
|
||||
this.dispatchStoreAction(this.storeActions.SAVE_VEHICLE_DAMAGE, {
|
||||
isWindshieldRepair: this.isWindshieldRepair,
|
||||
selectedGlassToReplace: this.selectedGlassToReplace(),
|
||||
selectedWindshieldChipCount: this.selectedWindshieldOptions.selectedWindshieldChipCount
|
||||
}, false);
|
||||
|
||||
this.navigateForward();
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export default {
|
|||
|
||||
watch: {
|
||||
selectedMake(make) {
|
||||
this.$store.dispatch(storeActions.SAVE_VEHICLE_MAKE, make);
|
||||
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false);
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_MAKE,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ export default {
|
|||
|
||||
watch: {
|
||||
selectedModel(model) {
|
||||
this.$store.dispatch(storeActions.SAVE_VEHICLE_MODEL, model);
|
||||
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MODEL, model, false);
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_MODEL,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export default {
|
|||
|
||||
watch: {
|
||||
selectedStyle(style) {
|
||||
this.$store.dispatch(storeActions.SAVE_VEHICLE_STYLE, style);
|
||||
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_STYLE, style, false);
|
||||
this.setVehicle().then(() => {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_STYLE,
|
||||
|
|
|
|||
|
|
@ -28,13 +28,11 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
|
|||
// Supporting files
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { experimentUniverses } from "@/constants/experiments";
|
||||
import { getDeviceIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
import store from "@/store";
|
||||
|
||||
export default {
|
||||
name: "vehicle-year",
|
||||
|
|
@ -89,7 +87,7 @@ export default {
|
|||
watch: {
|
||||
selectedYear(year) {
|
||||
const parsedYear = parseInt(year);
|
||||
this.$store.dispatch(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
|
||||
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_YEAR,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<alert
|
||||
class="my-4"
|
||||
v-model="customAlertData"
|
||||
v-if="noMatchAlert"
|
||||
alertClass="alert-warning"
|
||||
cmsWidgetName="NoMatchAlertWidget"
|
||||
/>
|
||||
<alert
|
||||
class="my-4"
|
||||
:manualHeadline="PerfectMatchInsuranceVerifiedAlertHeader"
|
||||
|
|
@ -139,6 +132,7 @@ import { getDamageString, getIsWindshieldOnly, isGlassAvailableForCarId } from "
|
|||
import { required, regex } from "@/helpers/validation-rules";
|
||||
import { Form, defineRule } from "vee-validate";
|
||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||
import { routerParams } from "@/router/router-constants/router-params";
|
||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
|
|
@ -248,13 +242,6 @@ export default {
|
|||
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);
|
||||
},
|
||||
getEmailFromStore(){
|
||||
return store.getters.order.customer.emailAddress;
|
||||
},
|
||||
|
|
@ -288,108 +275,101 @@ export default {
|
|||
}
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
let zipValidationResponse;
|
||||
let vehicleLookupResponse;
|
||||
|
||||
const zipValidation = this.validateZip(this.zip);
|
||||
|
||||
// If this is a new VIN Lookup, do both a Vehicle Lookup and a Zip Validation
|
||||
if (!this.vinPopulatedOnPageLoad) {
|
||||
// Perform Zip Validation
|
||||
zipValidationResponse = await zipValidation;
|
||||
if (!this.vinPopulatedOnPageLoad) {
|
||||
const validateZipResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.zip});
|
||||
const vehicleLookupResponse = this.dispatchStoreAction(storeActions.LOOKUP_VEHICLE_BY_VIN, { vin: this.vin });
|
||||
|
||||
// Perform Vehicle Lookup
|
||||
const vehicleLookup = this.lookupVehicle(this.vin);
|
||||
vehicleLookupResponse = await vehicleLookup.catch(() => {
|
||||
this.vinNotFound = true;
|
||||
return false;
|
||||
});
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: "validateZipResponse",
|
||||
promise: validateZipResponse,
|
||||
},
|
||||
{
|
||||
resultKey: "vehicleLookupResponse",
|
||||
promise: vehicleLookupResponse,
|
||||
},
|
||||
];
|
||||
|
||||
// Check if Service Zip entered is servicable, if not display an alert
|
||||
if (!zipValidationResponse.data.isServiceable) {
|
||||
this.setupUiForNonServiceableZip(this.zip);
|
||||
}
|
||||
|
||||
if (!vehicleLookupResponse || !zipValidationResponse.data.isServiceable) {
|
||||
// If either lookup fails, remove the loader and stop processing the page.
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId;
|
||||
|
||||
if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {
|
||||
this.previouslyEnteredCarId = vehicleLookupResponse.data.carId;
|
||||
this.noServiceZip = false;
|
||||
this.customAlertData.vehicleInfo = vehicleLookupResponse.data;
|
||||
this.$refs.funnelFooter.updateButtonText(`Continue with ${vehicleLookupResponse.data.year} ${vehicleLookupResponse.data.make} ${vehicleLookupResponse.data.model}`);
|
||||
this.isVinValid = true;
|
||||
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleLookupResponse.data.carId);
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
this.isCarIdDifferent = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data);
|
||||
this.navigateForward();
|
||||
|
||||
} else {
|
||||
// If a VIN has already been found. Validate the Service Zip (in case of changes)
|
||||
const zipValidationResponse = await zipValidation;
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
// Check if Service Zip entered is serviceable
|
||||
if (zipValidationResponse.data.isServiceable) {
|
||||
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.zip);
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, zipValidationResponse.data.state);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
this.navigateForward();
|
||||
} else {
|
||||
// If the Service Zip is NOT serviceable then show an alert
|
||||
this.setupUiForNonServiceableZip(this.zip);
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
// If either lookup fails, remove the loader and stop processing the page.
|
||||
if (!resultMap.vehicleLookupResponse || !resultMap.validateZipResponse.isServiceable) {
|
||||
|
||||
// If the vehicle result is undefined, the vin entered was invalid.
|
||||
if(!resultMap.vehicleLookupResponse) {
|
||||
this.vinNotFound = true;
|
||||
}
|
||||
|
||||
// Check if Service Zip entered is serviceable, if not display an alert
|
||||
if (!resultMap.validateZipResponse.isServiceable) {
|
||||
this.setupUiForNonServiceableZip(this.zip);
|
||||
}
|
||||
|
||||
// Remove loader and stop processing the page.
|
||||
return this.$refs.funnelFooter.removeLoader();
|
||||
}
|
||||
|
||||
// Check if the CarId is different from the lookup vs what is in state currently.
|
||||
this.isCarIdDifferent = resultMap.vehicleLookupResponse.carId !== this.$store.getters.vehicle.carId;
|
||||
|
||||
if (this.isCarIdDifferent && (resultMap.vehicleLookupResponse.carId !== this.previouslyEnteredCarId)) {
|
||||
|
||||
this.previouslyEnteredCarId = resultMap.vehicleLookupResponse.carId;
|
||||
this.customAlertData.vehicleInfo = resultMap.vehicleLookupResponse;
|
||||
this.$refs.funnelFooter.updateButtonText(`Continue with ${resultMap.vehicleLookupResponse.year} ${resultMap.vehicleLookupResponse.make} ${resultMap.vehicleLookupResponse.model}`);
|
||||
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(resultMap.vehicleLookupResponse.carId);
|
||||
|
||||
this.noServiceZip = false;
|
||||
this.isVinValid = true;
|
||||
return this.$refs.funnelFooter.removeLoader();
|
||||
}
|
||||
|
||||
// Save vin, vehicle, customer and service information
|
||||
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
|
||||
isCarIdDifferent: this.isCarIdDifferent,
|
||||
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
||||
vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }),
|
||||
serviceLocationInfo: {
|
||||
zipCode: this.zip,
|
||||
state: resultMap.validateZipResponse.state,
|
||||
},
|
||||
customerEmail: this.email,
|
||||
}, false);
|
||||
|
||||
this.navigateForward();
|
||||
}
|
||||
|
||||
// If a VIN has already been found. Validate the Service Zip (in case of changes)
|
||||
const zipValidationResponse = await this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.zip});
|
||||
|
||||
// Check if Service Zip entered is serviceable
|
||||
if (zipValidationResponse.data.isServiceable) {
|
||||
|
||||
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
|
||||
this.$store.commit(storeActions.UPDATE_SERVICE_LOCATION, {
|
||||
zipCode: this.zip,
|
||||
state: zipValidationResponse.data.state
|
||||
});
|
||||
|
||||
this.$store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
|
||||
this.navigateForward();
|
||||
}
|
||||
|
||||
// If the Service Zip is NOT serviceable then show an alert
|
||||
this.setupUiForNonServiceableZip(this.zip);
|
||||
|
||||
return this.$refs.funnelFooter.removeLoader();
|
||||
},
|
||||
navigateForward(){
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { displayVehicleChangeAlert: true }, {});
|
||||
return;
|
||||
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
|
||||
} else {
|
||||
this.navigateForwardWithSingleCarMatch();
|
||||
return;
|
||||
}
|
||||
},
|
||||
validateZip(zip) {
|
||||
return this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
||||
zip,
|
||||
});
|
||||
},
|
||||
lookupVehicle(vin) {
|
||||
return this.dispatchStoreAction(
|
||||
storeActions.LOOKUP_VEHICLE_BY_VIN,
|
||||
{ vin }
|
||||
);
|
||||
},
|
||||
updateStore(carInfo, zipInfo) {
|
||||
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
|
||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
store.commit(storeMutations.UPDATE_VEHICLE_VIN, this.vin);
|
||||
store.commit(storeMutations.UPDATE_YEAR, carInfo.year);
|
||||
store.commit(storeMutations.UPDATE_MAKE, carInfo.make);
|
||||
store.commit(storeMutations.UPDATE_MODEL, carInfo.model);
|
||||
store.commit(storeMutations.UPDATE_STYLE, carInfo.style);
|
||||
store.commit(storeMutations.UPDATE_CAR_ID, carInfo.carId);
|
||||
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, carInfo.category);
|
||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, carInfo.imageUrl);
|
||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, carInfo.imageVifNumber);
|
||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, carInfo.imageVifNumber);
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.zip);
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, zipInfo.state);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
},
|
||||
setupUiForNonServiceableZip(zip) {
|
||||
this.customAlertData.zip = zip;
|
||||
this.invalidZip = zip;
|
||||
|
|
|
|||
|
|
@ -149,9 +149,6 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
|
|||
if (destinationFmgPageValue !== undefined) {
|
||||
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
|
||||
|
||||
// If we need to do invalidation
|
||||
const currentComponent = currentRoute.matched[0].components;
|
||||
|
||||
// Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided.
|
||||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const getDefaultState = () => {
|
|||
model: null,
|
||||
style: null,
|
||||
carId: null,
|
||||
category: null,
|
||||
category: null,
|
||||
vin: null,
|
||||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
|
|
@ -49,7 +49,7 @@ const getDefaultState = () => {
|
|||
glassParts: null,
|
||||
otherParts: null
|
||||
},
|
||||
payment:{
|
||||
payment: {
|
||||
isInsurance: null,
|
||||
insuranceCoverage: {
|
||||
isVerified: null
|
||||
|
|
@ -70,9 +70,6 @@ const getDefaultState = () => {
|
|||
|
||||
export const state = getDefaultState();
|
||||
|
||||
const oldState = state;
|
||||
const newState = state;
|
||||
|
||||
// Export Mutations
|
||||
export const mutations = {
|
||||
// VEHICLE MUTATIONS
|
||||
|
|
@ -139,37 +136,65 @@ export const mutations = {
|
|||
updateInsuranceVerifiedStatus(state, isVerified) {
|
||||
state.order.payment.insuranceCoverage.isVerified = isVerified;
|
||||
},
|
||||
updateRegistrationLicensePlate(state, licensePlate){
|
||||
updateRegistrationLicensePlate(state, licensePlate) {
|
||||
state.order.vehicle.registration.licensePlate = licensePlate;
|
||||
},
|
||||
updateRegistrationAddress(state, registrationAddress){
|
||||
updateRegistrationAddress(state, registrationAddress) {
|
||||
state.order.vehicle.registration.address = registrationAddress;
|
||||
},
|
||||
updateRegistrationCity(state, registrationCity){
|
||||
updateRegistrationCity(state, registrationCity) {
|
||||
state.order.vehicle.registration.city = registrationCity;
|
||||
},
|
||||
updateRegistrationState(state, registrationState){
|
||||
},
|
||||
updateRegistrationState(state, registrationState) {
|
||||
state.order.vehicle.registration.state = registrationState;
|
||||
},
|
||||
updateRegistrationZipCode(state, registrationZipCode){
|
||||
updateRegistrationZipCode(state, registrationZipCode) {
|
||||
state.order.vehicle.registration.zipCode = registrationZipCode;
|
||||
},
|
||||
updateServiceLocationZipCode(state, serviceLocationZip){
|
||||
updateServiceLocationZipCode(state, serviceLocationZip) {
|
||||
state.order.serviceLocation.zipCode = serviceLocationZip;
|
||||
},
|
||||
updateServiceLocationState(state, serviceLocationState){
|
||||
},
|
||||
updateServiceLocationState(state, serviceLocationState) {
|
||||
state.order.serviceLocation.state = serviceLocationState;
|
||||
},
|
||||
updateRegistrationFirstName(state, firstName){
|
||||
},
|
||||
updateRegistrationFirstName(state, firstName) {
|
||||
state.order.vehicle.registration.firstName = firstName;
|
||||
},
|
||||
updateRegistrationLastName(state, lastName){
|
||||
updateRegistrationLastName(state, lastName) {
|
||||
state.order.vehicle.registration.lastName = lastName;
|
||||
},
|
||||
updateCustomerEmailAddress(state, customerEmailAddress){
|
||||
updateCustomerEmailAddress(state, customerEmailAddress) {
|
||||
state.order.customer.emailAddress = customerEmailAddress;
|
||||
},
|
||||
updateVehicle(state, vehicleInfo) {
|
||||
|
||||
state.order.vehicle.year = vehicleInfo.year;
|
||||
state.order.vehicle.make = vehicleInfo.make;
|
||||
state.order.vehicle.model = vehicleInfo.model;
|
||||
state.order.vehicle.style = vehicleInfo.style;
|
||||
state.order.vehicle.carId = vehicleInfo.carId;
|
||||
state.order.vehicle.category = vehicleInfo.category;
|
||||
state.order.vehicle.vin = vehicleInfo.vin;
|
||||
|
||||
state.order.vehicle.imageUrl = vehicleInfo.imageUrl;
|
||||
state.order.vehicle.imageVifNumber = vehicleInfo.imageVifNumber;
|
||||
state.order.vehicle.imageColor = vehicleInfo.imageVifColor;
|
||||
},
|
||||
updateRegistration(state, registrationInfo) {
|
||||
state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
|
||||
state.order.vehicle.registration.address = registrationInfo?.address;
|
||||
state.order.vehicle.registration.city = registrationInfo?.city;
|
||||
state.order.vehicle.registration.state = registrationInfo?.state;
|
||||
state.order.vehicle.registration.zipCode = registrationInfo?.zipCode;
|
||||
state.order.vehicle.registration.firstName = registrationInfo?.firstName;
|
||||
state.order.vehicle.registration.lastName = registrationInfo?.lastName;
|
||||
},
|
||||
updateServiceLocation(state, serviceLocationInfo) {
|
||||
state.order.serviceLocation.address = serviceLocationInfo.address;
|
||||
state.order.serviceLocation.city = serviceLocationInfo.city;
|
||||
state.order.serviceLocation.state = serviceLocationInfo.state;
|
||||
state.order.serviceLocation.zipCode = serviceLocationInfo.zipCode;
|
||||
},
|
||||
|
||||
// EVENT BUS MUTATIONS
|
||||
addEventToBus(state, event) {
|
||||
|
|
@ -246,8 +271,8 @@ export const mutations = {
|
|||
address: orderInformation.vehicle.registration.streetAddress,
|
||||
city: orderInformation.vehicle.registration.city,
|
||||
state: orderInformation.vehicle.registration.state,
|
||||
zipCode: orderInformation.vehicle.registration.zipCode,
|
||||
licensePlate: orderInformation.vehicle.registration.licensePlateNumber,
|
||||
zipCode: orderInformation.vehicle.registration.zipCode,
|
||||
licensePlate: orderInformation.vehicle.registration.licensePlateNumber,
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -258,9 +283,9 @@ export const mutations = {
|
|||
state.order.lineItems.glassParts = orderInformation.parts;
|
||||
state.order.accountNumber = orderInformation.accountNumber;
|
||||
state.order.serviceLocation.address = orderInformation.serviceLocation.streetAddress,
|
||||
state.order.serviceLocation.city = orderInformation.serviceLocation.city,
|
||||
state.order.serviceLocation.state = orderInformation.serviceLocation.state,
|
||||
state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode;
|
||||
state.order.serviceLocation.city = orderInformation.serviceLocation.city,
|
||||
state.order.serviceLocation.state = orderInformation.serviceLocation.state,
|
||||
state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode;
|
||||
|
||||
state.order.payment.isInsurance = orderInformation.IsInsuranceOrder;
|
||||
state.order.payment.insuranceCoverage.isVerified = orderInformation?.insuranceInfo.coverageVerified;
|
||||
|
|
@ -298,6 +323,7 @@ export const getters = {
|
|||
|
||||
// Export Actions
|
||||
export const actions = {
|
||||
|
||||
// Vehicle API Actions
|
||||
getVehicleYears(context) {
|
||||
return globalMethods.callHttpClient({
|
||||
|
|
@ -383,7 +409,7 @@ export const actions = {
|
|||
},
|
||||
getDamageOptions(context, { carId }) {
|
||||
return globalMethods.callHttpClient({
|
||||
methods: endpoints.GetDamageOptions.method,
|
||||
methods: endpoints.GetDamageOptions.method,
|
||||
endpoint: `${endpoints.GetDamageOptions.url}/${carId}`,
|
||||
payload: {},
|
||||
});
|
||||
|
|
@ -395,7 +421,7 @@ export const actions = {
|
|||
})
|
||||
},
|
||||
|
||||
// DEPENDENCY ACTIONS
|
||||
// Dependency Actions
|
||||
resetVehicleAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_VEHICLE_STATE);
|
||||
context.commit(storeMutations.RESET_DAMAGE_STATE);
|
||||
|
|
@ -439,37 +465,20 @@ export const actions = {
|
|||
payload: {},
|
||||
});
|
||||
},
|
||||
getEvoxImage(context, { relativeUrl }) {
|
||||
|
||||
// Analytics Actions
|
||||
logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetPageData.method,
|
||||
endpoint: relativeUrl,
|
||||
payload: {},
|
||||
method: endpoints.LogExperimentExposureIfAssigned.method,
|
||||
endpoint: endpoints.LogExperimentExposureIfAssigned.url,
|
||||
payload: {
|
||||
userId: userId,
|
||||
sessionKey: sessionKey,
|
||||
pageName: pageName,
|
||||
universeName: universeName
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Misc Actions
|
||||
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId }) {
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId);
|
||||
},
|
||||
updateServiceLocationWithVehicleRegistration(context) {
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
||||
},
|
||||
|
||||
logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.LogExperimentExposureIfAssigned.method,
|
||||
endpoint: endpoints.LogExperimentExposureIfAssigned.url,
|
||||
payload: {
|
||||
userId: userId,
|
||||
sessionKey: sessionKey,
|
||||
pageName: pageName,
|
||||
universeName: universeName
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
logPageView(context, { userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId }) {
|
||||
var payload = {
|
||||
userId: userId,
|
||||
|
|
@ -477,7 +486,7 @@ export const actions = {
|
|||
sessionId: sessionId,
|
||||
pageName: pageName,
|
||||
applicationName: 'SafeliteDotCom',
|
||||
action: action,
|
||||
action: action,
|
||||
event: event,
|
||||
shouldUseSessionId: shouldUseSessionId
|
||||
};
|
||||
|
|
@ -489,7 +498,6 @@ export const actions = {
|
|||
logApiCall: false
|
||||
});
|
||||
},
|
||||
|
||||
logCustomEvent(context, { userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId }) {
|
||||
var payload = {
|
||||
userId: userId,
|
||||
|
|
@ -497,9 +505,9 @@ export const actions = {
|
|||
sessionId: sessionId,
|
||||
pageName: pageName,
|
||||
applicationName: 'SafeliteDotCom',
|
||||
category: category,
|
||||
action: action,
|
||||
label: label,
|
||||
category: category,
|
||||
action: action,
|
||||
label: label,
|
||||
value: value,
|
||||
shouldUseSessionId: shouldUseSessionId
|
||||
};
|
||||
|
|
@ -511,7 +519,6 @@ export const actions = {
|
|||
logApiCall: false
|
||||
});
|
||||
},
|
||||
|
||||
initializeSession(context, { userId, sessionId, userAgent, referrer }) {
|
||||
var payload = {
|
||||
applicationName: 'SafeliteDotCom',
|
||||
|
|
@ -532,14 +539,30 @@ export const actions = {
|
|||
});
|
||||
},
|
||||
|
||||
GetExperimentsByUser(context, { userId }){
|
||||
// Misc Actions
|
||||
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId }) {
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_DATE, referralDate);
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, referralCorrelationId);
|
||||
},
|
||||
updateServiceLocationWithVehicleRegistration(context) {
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
||||
},
|
||||
|
||||
GetExperimentsByUser(context, { userId }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetExperimentsByUser.method,
|
||||
endpoint: `${endpoints.GetExperimentsByUser.url}/${userId}`,
|
||||
payload: {}
|
||||
});
|
||||
},
|
||||
|
||||
getEvoxImage(context, { relativeUrl }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetPageData.method,
|
||||
endpoint: relativeUrl,
|
||||
payload: {},
|
||||
});
|
||||
},
|
||||
|
||||
// Parts API Actions
|
||||
getPartsOrQuestions(context) {
|
||||
|
|
@ -611,8 +634,7 @@ export const actions = {
|
|||
},
|
||||
});
|
||||
},
|
||||
|
||||
loadOrder(context, { referralNumber, referralDate, referralCorrelationId, accountNumber}) {
|
||||
loadOrder(context, { referralNumber, referralDate, referralCorrelationId, accountNumber }) {
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.LoadOrder.method,
|
||||
endpoint: endpoints.LoadOrder.url,
|
||||
|
|
@ -629,11 +651,12 @@ export const actions = {
|
|||
});
|
||||
},
|
||||
|
||||
saveVehicleYear(context, year){
|
||||
|
||||
//If different year, reset state dependencies
|
||||
if(state.order.vehicle.year!==year){
|
||||
context.commit(storeMutations.UPDATE_YEAR, null);
|
||||
// Business domain actions
|
||||
|
||||
saveVehicleYear(context, year) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (context.state.order.vehicle.year !== year) {
|
||||
context.commit(storeMutations.UPDATE_MAKE, null);
|
||||
context.commit(storeMutations.UPDATE_MODEL, null);
|
||||
context.commit(storeMutations.UPDATE_STYLE, null);
|
||||
|
|
@ -643,17 +666,18 @@ export const actions = {
|
|||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
|
||||
|
||||
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
}
|
||||
|
||||
//Update vehicle year
|
||||
state.order.vehicle.year = year;
|
||||
//Save new values
|
||||
context.commit(storeMutations.UPDATE_YEAR, year);
|
||||
},
|
||||
saveVehicleMake(context, make){
|
||||
//If new make, reset state dependencies
|
||||
if(state.order.vehicle.make !== make){
|
||||
saveVehicleMake(context, make) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (context.state.order.vehicle.make !== make) {
|
||||
context.commit(storeMutations.UPDATE_MODEL, null);
|
||||
context.commit(storeMutations.UPDATE_STYLE, null);
|
||||
context.commit(storeMutations.UPDATE_CAR_ID, null);
|
||||
|
|
@ -663,17 +687,17 @@ export const actions = {
|
|||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
|
||||
|
||||
// Invokes
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
//Update vehicle make
|
||||
state.order.vehicle.make = make;
|
||||
},
|
||||
saveVehicleModel(context, model){
|
||||
|
||||
//If new model, reset state dependencies
|
||||
if (state.order.vehicle.make !== model) {
|
||||
//Save new values
|
||||
context.commit(storeMutations.UPDATE_MAKE, make);
|
||||
},
|
||||
saveVehicleModel(context, model) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (context.state.order.vehicle.model !== model) {
|
||||
context.commit(storeMutations.UPDATE_STYLE, null);
|
||||
context.commit(storeMutations.UPDATE_CAR_ID, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
|
||||
|
|
@ -685,12 +709,14 @@ export const actions = {
|
|||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
//Update vehicle model
|
||||
state.order.vehicle.model = model;
|
||||
|
||||
//Save new values
|
||||
context.commit(storeMutations.UPDATE_MODEL, model);
|
||||
},
|
||||
saveVehicleStyle(context, style){
|
||||
//If new style, reset state dependencies
|
||||
if(state.order.vehicle.style !== style){
|
||||
saveVehicleStyle(context, style) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (context.state.order.vehicle.style !== style) {
|
||||
context.commit(storeMutations.UPDATE_CAR_ID, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
|
||||
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
|
||||
|
|
@ -699,58 +725,112 @@ export const actions = {
|
|||
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
|
||||
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
//Update vehicle style
|
||||
state.order.vehicle.style = style;
|
||||
},
|
||||
saveVehicleDamage(context){
|
||||
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||
},
|
||||
saveVinLookup(context){
|
||||
//if cardId is different AND selected glass part is not available reset damage and dependeices
|
||||
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
|
||||
//Save new values
|
||||
context.commit(storeMutations.UPDATE_STYLE, style);
|
||||
},
|
||||
saveVehicleDamage(context, { isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount }) {
|
||||
|
||||
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||
const isGlassToReplaceTheSame = (context.state.order.damage.glassToReplace?.length === selectedGlassToReplace.length)
|
||||
&& context.state.order.damage.glassToReplace
|
||||
.slice()
|
||||
.sort()
|
||||
.every((obj, index) => obj.glassLocation === selectedGlassPassedInSorted[index].glassLocation && obj.glassName === selectedGlassPassedInSorted[index].glassName);
|
||||
|
||||
if (!isGlassToReplaceTheSame) {
|
||||
//Reset dependent state when changing
|
||||
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||
|
||||
// Save new values
|
||||
context.commit(storeMutations.UPDATE_IS_REPAIR, isWindshieldRepair);
|
||||
context.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, isWindshieldRepair ? parseInt(selectedWindshieldChipCount) : null);
|
||||
context.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, selectedGlassToReplace);
|
||||
}
|
||||
},
|
||||
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (registrationInfo?.licensePlate !== context.state.order.registration?.licensePlate) {
|
||||
|
||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
|
||||
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
||||
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
}
|
||||
|
||||
//Save new values
|
||||
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
|
||||
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, customerEmail);
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo);
|
||||
},
|
||||
|
||||
saveRegistrationLicensePlateLookup(context, { registrationInfo, serviceState, serviceZip, customerEmail, vehicleInfo, isCarIdDifferent, isSelectedGlassAvailableForVehicle }) {
|
||||
|
||||
if (registrationInfo.licensePlate !== context.state.order.registration.licensePlate || registrationInfo.zipcode !== context.state.order.registration.zipcode) {
|
||||
|
||||
//Reset dependent state when changing
|
||||
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
||||
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
|
||||
//Save new values
|
||||
context.dispatch(storeActions.SAVE_VIN_LOOKUP, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo });
|
||||
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, registrationInfo.licensePlate);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationInfo.state);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, registrationInfo.zipCode);
|
||||
|
||||
context.dispatch(storeActions.SAVE_SERVICE_ZIP, serviceZip);
|
||||
context.dispatch(storeActions.SAVE_SERVICE_STATE, serviceState);
|
||||
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
|
||||
}
|
||||
},
|
||||
saveRegistrationAddressLookup(context, { licensePlate }) {
|
||||
|
||||
|
||||
if (context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle) {
|
||||
storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES;
|
||||
}
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
},
|
||||
saveServiceLocation(context, { zipcode, state }) {
|
||||
if (zipcode !== context.state.order.service.zipcode || state !== context.state.order.service.state) {
|
||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, zipcode);
|
||||
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, state);
|
||||
}
|
||||
},
|
||||
saveEmail(context, email) {
|
||||
if (email !== context.state.order.customer.email) {
|
||||
context.commit(storeMutations.UPDATE_CUSTOM, email);
|
||||
}
|
||||
},
|
||||
saveVin(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo }) {
|
||||
|
||||
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
||||
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
|
||||
context.dispatch(storeActions.UPDATE_VEHICLE_INFO, vehicleInfo);
|
||||
},
|
||||
savePartQuestionAnswers(context) {
|
||||
// to be implemented later
|
||||
},
|
||||
saveGlassParts(context) {
|
||||
// to be implemented later
|
||||
}
|
||||
context.dispatch(storeMutations.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||
},
|
||||
saveServiceLocation(context){
|
||||
// to be implemented
|
||||
},
|
||||
saveEmail(context){
|
||||
// to be implemented
|
||||
},
|
||||
saveRegistrationLicensePlateLookup(context){
|
||||
//if cardId is different AND selected glass part is not available reset damage and dependeices
|
||||
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
|
||||
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
},
|
||||
saveVin(context){
|
||||
//if cardId is different AND selected glass part is not available reset damage and dependeices
|
||||
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
|
||||
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
},
|
||||
saveRegistrationAddressLookup(context){
|
||||
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){
|
||||
storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES;
|
||||
}
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
},
|
||||
savePartQuestionAnswers(context){
|
||||
// to be implemented later
|
||||
},
|
||||
saveGlassParts(context){
|
||||
// to be implemented later
|
||||
}
|
||||
}
|
||||
|
||||
export default createStore({
|
||||
|
|
@ -767,4 +847,4 @@ export default createStore({
|
|||
});
|
||||
|
||||
// Private Functions
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue