Init refactor

This commit is contained in:
FrankRua 2022-06-28 17:01:28 -04:00
parent 1fae6c5bde
commit 3226ec4e6e
12 changed files with 406 additions and 342 deletions

View file

@ -24,6 +24,7 @@ const storeActions = {
INITIALIZE_SESSION: "initializeSession", INITIALIZE_SESSION: "initializeSession",
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration", UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION: "updateServiceLocationWithVehicleRegistration",
UPDATE_VEHICLE_INFO: 'updateVehicleInfo',
// DEPENDENCY MUTATIONS // DEPENDENCY MUTATIONS
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",

View file

@ -11,10 +11,13 @@ const storeMutations = {
UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber", UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber",
UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor", UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor",
UPDATE_VEHICLE_VIN: "updateVehicleVin", UPDATE_VEHICLE_VIN: "updateVehicleVin",
UPDATE_VEHICLE: "updateVehicle",
UPDATE_IS_REPAIR: "updateIsRepair", UPDATE_IS_REPAIR: "updateIsRepair",
UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips", UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips",
UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace", UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace",
UPDATE_GLASS_PARTS: "updateGlassParts", UPDATE_GLASS_PARTS: "updateGlassParts",
UPDATE_REGISTRATION_LICENSE_PLATE : "updateRegistrationLicensePlate", UPDATE_REGISTRATION_LICENSE_PLATE : "updateRegistrationLicensePlate",
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress", UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
UPDATE_REGISTRATION_CITY: "updateRegistrationCity", UPDATE_REGISTRATION_CITY: "updateRegistrationCity",
@ -22,8 +25,12 @@ const storeMutations = {
UPDATE_REGISTRATION_ZIP_CODE: "updateRegistrationZipCode", UPDATE_REGISTRATION_ZIP_CODE: "updateRegistrationZipCode",
UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName", UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName",
UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName", UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName",
UPDATE_REGISTRATION: "updateRegistration",
UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode", UPDATE_SERVICE_LOCATION_ZIP_CODE: "updateServiceLocationZipCode",
UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState", UPDATE_SERVICE_LOCATION_STATE: "updateServiceLocationState",
UPDATE_SERVICE_LOCATION: "updateServiceLocation",
UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress",
// ORDER MUTATIONS // ORDER MUTATIONS

View file

@ -183,7 +183,7 @@ export default {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,
this.$route, this.$route,
{}, {},
{ displayVehicleChangeAlert: true }, { displayVehicleChangeAlert: true },
); );
return; return;
@ -198,10 +198,7 @@ export default {
{ vin } { vin }
); );
}, },
resetDependentState() { // needed because navigateAfterSaveToHeritageFunnel calls it //this.dispatchStoreAction(storeActions.SAVE_VIN, vin,vehicle),
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
},
//this.$store.dispatch(storeActions.SAVE_VIN, vin,vehicle),
updateCustomerInfo(vin, vehicle) { updateCustomerInfo(vin, vehicle) {
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.dispatchStoreAction(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); this.dispatchStoreAction(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);

View file

@ -1,9 +1,17 @@
<template> <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"> <div class="page-container-grouped-styles">
<loadingModal ref="loadingModal"/> <loadingModal ref="loadingModal" />
<funnelHeader cmsWidgetName="FunnelHeaderWidget" /> <funnelHeader cmsWidgetName="FunnelHeaderWidget" />
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="false" /> <vehicleBanner
cmsWidgetName="VehicleBannerWidget"
:displayGenericVehicleImage="false"
/>
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" /> <funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<div class="fade-on-route-transition sub-container make-tall"> <div class="fade-on-route-transition sub-container make-tall">
<div class="row my-2"> <div class="row my-2">
@ -56,11 +64,14 @@
/> />
</div> </div>
</div> </div>
<alert class="my-3" <alert
cmsWidgetName="NoMatchAlertWidget" class="my-3"
cmsWidgetName="NoMatchAlertWidget"
v-if="!isVinValid" v-if="!isVinValid"
alertClass="alert-warning" /> alertClass="alert-warning"
<alert class="my-3" />
<alert
class="my-3"
:manualHeadline="MatchedDifferentVehicleAlertHeader" :manualHeadline="MatchedDifferentVehicleAlertHeader"
:manualCopy="MatchedDifferentVehicleAlertBody" :manualCopy="MatchedDifferentVehicleAlertBody"
v-if="isCarIdDifferent" v-if="isCarIdDifferent"
@ -78,7 +89,6 @@
</Form> </Form>
</template> </template>
<script> <script>
// Components // Components
import funnelHeader from "@/common-components/funnel-header/funnel-header"; 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 funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
import alert from "@/ux-components/alert/alert"; 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";
import loadingModal from '@/common-components/loading-modal/loading-modal.vue'; import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
// Supporting files // Supporting files
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";
@ -95,17 +105,35 @@ import store from "@/store";
import { storeActions } from "@/constants/store-actions"; import { storeActions } from "@/constants/store-actions";
import { storeMutations } from "@/constants/store-mutations"; import { storeMutations } from "@/constants/store-mutations";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { getDamageString, isGlassAvailableForCarId, } from "@/helpers/damage-helper"; import {
import { required, regex, } from "@/helpers/validation-rules"; getDamageString,
import { Form, defineRule, } from "vee-validate"; 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"; import vinPagesMixin from "@/mixins/vin-pages-mixin";
// DEFINE VALIDATION RULES // 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-required", required(errorMessages.REGISTRATION_ZIP_REQUIRED));
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT)); defineRule(
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED)); "zip-format",
defineRule("email-address-format", regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,})$/, errorMessages.EMAIL_ADDRESS_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 { export default {
name: "license-plate-lookup", name: "license-plate-lookup",
@ -191,21 +219,14 @@ export default {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null; 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() { attachCustomEvents() {
this.prependActionToMethod(this, this.forwardButtonAction, () => { this.prependActionToMethod(this, this.forwardButtonAction, () => {
this.pushEventToGA( this.pushEventToGA(
this.$route.query[this.queryStrings.FMG_PAGE], this.$route.query[this.queryStrings.FMG_PAGE],
this.GaActions.SUBMITTED, this.GaActions.SUBMITTED,
this.GaLabels.LICENSE_PLATE_LOOKUP, this.GaLabels.LICENSE_PLATE_LOOKUP,
true true
); );
}); });
}, },
getLicensePlateFromStore() { getLicensePlateFromStore() {
@ -226,9 +247,10 @@ export default {
async forwardButtonAction() { async forwardButtonAction() {
//Call zip validation services //Call zip validation services
const registrationZipValidationPromise = this.validateZip(this.registrationZip); const registrationZipValidationPromise = this.validateZip(this.registrationZip);
const serviceZipValidationPromise = this.serviceZip ? this.validateZip(this.serviceZip) : null;
const registrationZipValidationResults = await registrationZipValidationPromise; 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 //Handle service zip validations
if (!serviceZipValidationResults.data.isServiceable) { if (!serviceZipValidationResults.data.isServiceable) {
@ -236,11 +258,13 @@ export default {
this.isVinValid = true; this.isVinValid = true;
this.isRegistrationZipServicable = false; this.isRegistrationZipServicable = false;
this.isCarIdDifferent = false; this.isCarIdDifferent = false;
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip; this.zipToDisplay = this.serviceZip
? this.serviceZip
: this.registrationZip;
return; return;
} else if (!this.serviceZip) { } else if (!this.serviceZip) {
this.serviceZip = this.registrationZip; this.serviceZip = this.registrationZip;
} }
//Lookup vin //Lookup vin
const vinLookup = await this.lookupVin( const vinLookup = await this.lookupVin(
@ -252,7 +276,7 @@ export default {
this.isCarIdDifferent = false; this.isCarIdDifferent = false;
return; return;
}); });
this.isCarIdDifferent = this.isCarIdDifferent =
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId; vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
@ -272,13 +296,13 @@ export default {
return; return;
} }
//Save // Save vin and vehicle information
this.updateCustomerInfo( this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
vinLookup.data.vin, isCarIdDifferent: this.isCarIdDifferent,
vinLookup.data.vehicle, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
registrationZipValidationResults.data.state, vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin})
serviceZipValidationResults.data.state });
);
//Navigate //Navigate
this.navigateForward(); this.navigateForward();
@ -304,28 +328,11 @@ export default {
}); });
}, },
lookupVin(plate, state) { lookupVin(plate, state) {
return this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false); return this.dispatchStoreAction(
}, storeActions.LOOKUP_VIN_BY_PLATE,
updateCustomerInfo(vin, vehicleInfo, registrationState, serviceState) { { licensePlate: plate, licenseState: state },
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { false
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);
}, },
}, },
watch: { watch: {

View file

@ -184,16 +184,16 @@ export default {
getDamageLocationsFromStore() { getDamageLocationsFromStore() {
var glassSelections = []; 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) { store.getters.damage.isRepair) {
glassSelections.push(damageLocationsSelected.WINDSHIELD); glassSelections.push(damageLocationsSelected.WINDSHIELD);
} }
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER || if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER ||
glass.location === damageLocationsSelected.PASSENGER })) { glass.glassLocation === damageLocationsSelected.PASSENGER })) {
glassSelections.push(damageLocationsSelected.SIDEDOOR); 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); glassSelections.push(damageLocationsSelected.REARWINDOW);
} }
@ -206,20 +206,20 @@ export default {
if (store.getters.damage.isRepair === undefined) return windshieldOptions; if (store.getters.damage.isRepair === undefined) return windshieldOptions;
if (!store.getters.damage.isRepair) { if (!store.getters.damage.isRepair) {
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.name === damageLocationsSelected.SINGLE })) { glass.glassName === damageLocationsSelected.SINGLE })) {
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE); windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE); windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE);
} }
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.name === damageLocationsSelected.DRIVER })) { glass.glassName === damageLocationsSelected.DRIVER })) {
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE); windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER); windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER);
} }
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.name === damageLocationsSelected.PASSENGER })) { glass.glassName === damageLocationsSelected.PASSENGER })) {
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE); windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER); windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER);
} }
@ -236,11 +236,11 @@ export default {
getDoorSidesFromStore() { getDoorSidesFromStore() {
var doorSides = []; 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); 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); doorSides.push(damageLocationsSelected.PASSENGERSIDE);
} }
@ -251,8 +251,8 @@ export default {
var driverSideReplaceOptions = []; var driverSideReplaceOptions = [];
store.getters.damage.glassToReplace?.forEach(glass => { store.getters.damage.glassToReplace?.forEach(glass => {
if (glass.location === damageLocationsSelected.DRIVER){ if (glass.glassLocation === damageLocationsSelected.DRIVER){
driverSideReplaceOptions.push(glass.name); driverSideReplaceOptions.push(glass.glassName);
} }
}); });
@ -263,8 +263,8 @@ export default {
var passengerSideReplaceOptions = []; var passengerSideReplaceOptions = [];
store.getters.damage.glassToReplace?.forEach(glass => { store.getters.damage.glassToReplace?.forEach(glass => {
if (glass.location === damageLocationsSelected.PASSENGER){ if (glass.glassLocation === damageLocationsSelected.PASSENGER){
passengerSideReplaceOptions.push(glass.name); passengerSideReplaceOptions.push(glass.glassName);
} }
}); });
@ -275,8 +275,8 @@ export default {
var rearReplaceOptions = []; var rearReplaceOptions = [];
store.getters.damage.glassToReplace?.forEach(glass => { store.getters.damage.glassToReplace?.forEach(glass => {
if (glass.location === damageLocationsSelected.REAR){ if (glass.glassLocation === damageLocationsSelected.REAR){
rearReplaceOptions.push(glass.name); rearReplaceOptions.push(glass.glassName);
} }
}); });
@ -284,16 +284,13 @@ export default {
}, },
async forwardButtonAction() { 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(); this.navigateForward();
}, },

View file

@ -85,7 +85,7 @@ export default {
watch: { watch: {
selectedMake(make) { selectedMake(make) {
this.$store.dispatch(storeActions.SAVE_VEHICLE_MAKE, make); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MAKE, make, false);
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.SELECTED_MAKE, this.navigationScenarios.SELECTED_MAKE,
this.$route this.$route

View file

@ -86,7 +86,7 @@ export default {
watch: { watch: {
selectedModel(model) { selectedModel(model) {
this.$store.dispatch(storeActions.SAVE_VEHICLE_MODEL, model); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_MODEL, model, false);
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.SELECTED_MODEL, this.navigationScenarios.SELECTED_MODEL,
this.$route this.$route

View file

@ -97,7 +97,7 @@ export default {
watch: { watch: {
selectedStyle(style) { selectedStyle(style) {
this.$store.dispatch(storeActions.SAVE_VEHICLE_STYLE, style); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_STYLE, style, false);
this.setVehicle().then(() => { this.setVehicle().then(() => {
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.SELECTED_STYLE, this.navigationScenarios.SELECTED_STYLE,

View file

@ -28,13 +28,11 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
// Supporting files // Supporting files
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 { storeMutations } from "@/constants/store-mutations";
import { storeActions } from "@/constants/store-actions"; import { storeActions } from "@/constants/store-actions";
import { experimentUniverses } from "@/constants/experiments"; import { experimentUniverses } from "@/constants/experiments";
import { getDeviceIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper"; import { getDeviceIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
import baseMixin from "@/mixins/base-mixin"; import baseMixin from "@/mixins/base-mixin";
import store from "@/store";
export default { export default {
name: "vehicle-year", name: "vehicle-year",
@ -89,7 +87,7 @@ export default {
watch: { watch: {
selectedYear(year) { selectedYear(year) {
const parsedYear = parseInt(year); const parsedYear = parseInt(year);
this.$store.dispatch(storeActions.SAVE_VEHICLE_YEAR, parsedYear); this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.SELECTED_YEAR, this.navigationScenarios.SELECTED_YEAR,
this.$route this.$route

View file

@ -59,13 +59,6 @@
/> />
</div> </div>
</div> </div>
<alert
class="my-4"
v-model="customAlertData"
v-if="noMatchAlert"
alertClass="alert-warning"
cmsWidgetName="NoMatchAlertWidget"
/>
<alert <alert
class="my-4" class="my-4"
:manualHeadline="PerfectMatchInsuranceVerifiedAlertHeader" :manualHeadline="PerfectMatchInsuranceVerifiedAlertHeader"
@ -139,6 +132,7 @@ import { getDamageString, getIsWindshieldOnly, isGlassAvailableForCarId } from "
import { required, regex } from "@/helpers/validation-rules"; import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import { routerParams } from "@/router/router-constants/router-params";
import vinPagesMixin from "@/mixins/vin-pages-mixin"; import vinPagesMixin from "@/mixins/vin-pages-mixin";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
@ -248,13 +242,6 @@ export default {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null; 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(){ getEmailFromStore(){
return store.getters.order.customer.emailAddress; return store.getters.order.customer.emailAddress;
}, },
@ -288,108 +275,101 @@ export default {
} }
}, },
async forwardButtonAction() { 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 is a new VIN Lookup, do both a Vehicle Lookup and a Zip Validation
if (!this.vinPopulatedOnPageLoad) { if (!this.vinPopulatedOnPageLoad) {
// Perform Zip Validation const validateZipResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.zip});
zipValidationResponse = await zipValidation; const vehicleLookupResponse = this.dispatchStoreAction(storeActions.LOOKUP_VEHICLE_BY_VIN, { vin: this.vin });
// Perform Vehicle Lookup // Settle promises and get results
const vehicleLookup = this.lookupVehicle(this.vin); const promiseResultMap = [
vehicleLookupResponse = await vehicleLookup.catch(() => { {
this.vinNotFound = true; resultKey: "validateZipResponse",
return false; promise: validateZipResponse,
}); },
{
resultKey: "vehicleLookupResponse",
promise: vehicleLookupResponse,
},
];
// Check if Service Zip entered is servicable, if not display an alert const resultMap = await settleAllPromises(promiseResultMap);
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;
// Check if Service Zip entered is serviceable // If either lookup fails, remove the loader and stop processing the page.
if (zipValidationResponse.data.isServiceable) { if (!resultMap.vehicleLookupResponse || !resultMap.validateZipResponse.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); // If the vehicle result is undefined, the vin entered was invalid.
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, zipValidationResponse.data.state); if(!resultMap.vehicleLookupResponse) {
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); this.vinNotFound = true;
this.navigateForward(); }
} else {
// If the Service Zip is NOT serviceable then show an alert // Check if Service Zip entered is serviceable, if not display an alert
this.setupUiForNonServiceableZip(this.zip); if (!resultMap.validateZipResponse.isServiceable) {
this.$refs.funnelFooter.removeLoader(); 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(){ navigateForward(){
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) { if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { displayVehicleChangeAlert: true }, {}); this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
return;
} else { } else {
this.navigateForwardWithSingleCarMatch(); 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) { setupUiForNonServiceableZip(zip) {
this.customAlertData.zip = zip; this.customAlertData.zip = zip;
this.invalidZip = zip; this.invalidZip = zip;

View file

@ -149,9 +149,6 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
if (destinationFmgPageValue !== undefined) { 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. // 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. // 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); baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);

View file

@ -16,7 +16,7 @@ const getDefaultState = () => {
model: null, model: null,
style: null, style: null,
carId: null, carId: null,
category: null, category: null,
vin: null, vin: null,
imageUrl: null, imageUrl: null,
imageVifNumber: null, imageVifNumber: null,
@ -49,7 +49,7 @@ const getDefaultState = () => {
glassParts: null, glassParts: null,
otherParts: null otherParts: null
}, },
payment:{ payment: {
isInsurance: null, isInsurance: null,
insuranceCoverage: { insuranceCoverage: {
isVerified: null isVerified: null
@ -70,9 +70,6 @@ const getDefaultState = () => {
export const state = getDefaultState(); export const state = getDefaultState();
const oldState = state;
const newState = state;
// Export Mutations // Export Mutations
export const mutations = { export const mutations = {
// VEHICLE MUTATIONS // VEHICLE MUTATIONS
@ -139,37 +136,65 @@ export const mutations = {
updateInsuranceVerifiedStatus(state, isVerified) { updateInsuranceVerifiedStatus(state, isVerified) {
state.order.payment.insuranceCoverage.isVerified = isVerified; state.order.payment.insuranceCoverage.isVerified = isVerified;
}, },
updateRegistrationLicensePlate(state, licensePlate){ updateRegistrationLicensePlate(state, licensePlate) {
state.order.vehicle.registration.licensePlate = licensePlate; state.order.vehicle.registration.licensePlate = licensePlate;
}, },
updateRegistrationAddress(state, registrationAddress){ updateRegistrationAddress(state, registrationAddress) {
state.order.vehicle.registration.address = registrationAddress; state.order.vehicle.registration.address = registrationAddress;
}, },
updateRegistrationCity(state, registrationCity){ updateRegistrationCity(state, registrationCity) {
state.order.vehicle.registration.city = registrationCity; state.order.vehicle.registration.city = registrationCity;
}, },
updateRegistrationState(state, registrationState){ updateRegistrationState(state, registrationState) {
state.order.vehicle.registration.state = registrationState; state.order.vehicle.registration.state = registrationState;
}, },
updateRegistrationZipCode(state, registrationZipCode){ updateRegistrationZipCode(state, registrationZipCode) {
state.order.vehicle.registration.zipCode = registrationZipCode; state.order.vehicle.registration.zipCode = registrationZipCode;
}, },
updateServiceLocationZipCode(state, serviceLocationZip){ updateServiceLocationZipCode(state, serviceLocationZip) {
state.order.serviceLocation.zipCode = serviceLocationZip; state.order.serviceLocation.zipCode = serviceLocationZip;
}, },
updateServiceLocationState(state, serviceLocationState){ updateServiceLocationState(state, serviceLocationState) {
state.order.serviceLocation.state = serviceLocationState; state.order.serviceLocation.state = serviceLocationState;
}, },
updateRegistrationFirstName(state, firstName){ updateRegistrationFirstName(state, firstName) {
state.order.vehicle.registration.firstName = firstName; state.order.vehicle.registration.firstName = firstName;
}, },
updateRegistrationLastName(state, lastName){ updateRegistrationLastName(state, lastName) {
state.order.vehicle.registration.lastName = lastName; state.order.vehicle.registration.lastName = lastName;
}, },
updateCustomerEmailAddress(state, customerEmailAddress){ updateCustomerEmailAddress(state, customerEmailAddress) {
state.order.customer.emailAddress = 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 // EVENT BUS MUTATIONS
addEventToBus(state, event) { addEventToBus(state, event) {
@ -246,8 +271,8 @@ export const mutations = {
address: orderInformation.vehicle.registration.streetAddress, address: orderInformation.vehicle.registration.streetAddress,
city: orderInformation.vehicle.registration.city, city: orderInformation.vehicle.registration.city,
state: orderInformation.vehicle.registration.state, state: orderInformation.vehicle.registration.state,
zipCode: orderInformation.vehicle.registration.zipCode, zipCode: orderInformation.vehicle.registration.zipCode,
licensePlate: orderInformation.vehicle.registration.licensePlateNumber, licensePlate: orderInformation.vehicle.registration.licensePlateNumber,
} }
}); });
@ -258,9 +283,9 @@ export const mutations = {
state.order.lineItems.glassParts = orderInformation.parts; state.order.lineItems.glassParts = orderInformation.parts;
state.order.accountNumber = orderInformation.accountNumber; state.order.accountNumber = orderInformation.accountNumber;
state.order.serviceLocation.address = orderInformation.serviceLocation.streetAddress, state.order.serviceLocation.address = orderInformation.serviceLocation.streetAddress,
state.order.serviceLocation.city = orderInformation.serviceLocation.city, state.order.serviceLocation.city = orderInformation.serviceLocation.city,
state.order.serviceLocation.state = orderInformation.serviceLocation.state, state.order.serviceLocation.state = orderInformation.serviceLocation.state,
state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode; state.order.serviceLocation.zipCode = orderInformation.serviceLocation.zipCode;
state.order.payment.isInsurance = orderInformation.IsInsuranceOrder; state.order.payment.isInsurance = orderInformation.IsInsuranceOrder;
state.order.payment.insuranceCoverage.isVerified = orderInformation?.insuranceInfo.coverageVerified; state.order.payment.insuranceCoverage.isVerified = orderInformation?.insuranceInfo.coverageVerified;
@ -298,6 +323,7 @@ export const getters = {
// Export Actions // Export Actions
export const actions = { export const actions = {
// Vehicle API Actions // Vehicle API Actions
getVehicleYears(context) { getVehicleYears(context) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
@ -383,7 +409,7 @@ export const actions = {
}, },
getDamageOptions(context, { carId }) { getDamageOptions(context, { carId }) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
methods: endpoints.GetDamageOptions.method, methods: endpoints.GetDamageOptions.method,
endpoint: `${endpoints.GetDamageOptions.url}/${carId}`, endpoint: `${endpoints.GetDamageOptions.url}/${carId}`,
payload: {}, payload: {},
}); });
@ -395,7 +421,7 @@ export const actions = {
}) })
}, },
// DEPENDENCY ACTIONS // Dependency Actions
resetVehicleAndDependencies(context) { resetVehicleAndDependencies(context) {
context.commit(storeMutations.RESET_VEHICLE_STATE); context.commit(storeMutations.RESET_VEHICLE_STATE);
context.commit(storeMutations.RESET_DAMAGE_STATE); context.commit(storeMutations.RESET_DAMAGE_STATE);
@ -439,37 +465,20 @@ export const actions = {
payload: {}, payload: {},
}); });
}, },
getEvoxImage(context, { relativeUrl }) {
// Analytics Actions
logExperimentExposure(context, { userId, sessionKey, pageName, universeName }) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.GetPageData.method, method: endpoints.LogExperimentExposureIfAssigned.method,
endpoint: relativeUrl, endpoint: endpoints.LogExperimentExposureIfAssigned.url,
payload: {}, 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 }) { logPageView(context, { userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId }) {
var payload = { var payload = {
userId: userId, userId: userId,
@ -477,7 +486,7 @@ export const actions = {
sessionId: sessionId, sessionId: sessionId,
pageName: pageName, pageName: pageName,
applicationName: 'SafeliteDotCom', applicationName: 'SafeliteDotCom',
action: action, action: action,
event: event, event: event,
shouldUseSessionId: shouldUseSessionId shouldUseSessionId: shouldUseSessionId
}; };
@ -489,7 +498,6 @@ export const actions = {
logApiCall: false logApiCall: false
}); });
}, },
logCustomEvent(context, { userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId }) { logCustomEvent(context, { userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId }) {
var payload = { var payload = {
userId: userId, userId: userId,
@ -497,9 +505,9 @@ export const actions = {
sessionId: sessionId, sessionId: sessionId,
pageName: pageName, pageName: pageName,
applicationName: 'SafeliteDotCom', applicationName: 'SafeliteDotCom',
category: category, category: category,
action: action, action: action,
label: label, label: label,
value: value, value: value,
shouldUseSessionId: shouldUseSessionId shouldUseSessionId: shouldUseSessionId
}; };
@ -511,7 +519,6 @@ export const actions = {
logApiCall: false logApiCall: false
}); });
}, },
initializeSession(context, { userId, sessionId, userAgent, referrer }) { initializeSession(context, { userId, sessionId, userAgent, referrer }) {
var payload = { var payload = {
applicationName: 'SafeliteDotCom', 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({ return globalMethods.callHttpClient({
method: endpoints.GetExperimentsByUser.method, method: endpoints.GetExperimentsByUser.method,
endpoint: `${endpoints.GetExperimentsByUser.url}/${userId}`, endpoint: `${endpoints.GetExperimentsByUser.url}/${userId}`,
payload: {} payload: {}
}); });
}, },
getEvoxImage(context, { relativeUrl }) {
return globalMethods.callHttpClient({
method: endpoints.GetPageData.method,
endpoint: relativeUrl,
payload: {},
});
},
// Parts API Actions // Parts API Actions
getPartsOrQuestions(context) { getPartsOrQuestions(context) {
@ -611,8 +634,7 @@ export const actions = {
}, },
}); });
}, },
loadOrder(context, { referralNumber, referralDate, referralCorrelationId, accountNumber }) {
loadOrder(context, { referralNumber, referralDate, referralCorrelationId, accountNumber}) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
method: endpoints.LoadOrder.method, method: endpoints.LoadOrder.method,
endpoint: endpoints.LoadOrder.url, endpoint: endpoints.LoadOrder.url,
@ -629,11 +651,12 @@ export const actions = {
}); });
}, },
saveVehicleYear(context, year){ // Business domain actions
//If different year, reset state dependencies saveVehicleYear(context, year) {
if(state.order.vehicle.year!==year){
context.commit(storeMutations.UPDATE_YEAR, null); //Reset dependent state when changing
if (context.state.order.vehicle.year !== year) {
context.commit(storeMutations.UPDATE_MAKE, null); context.commit(storeMutations.UPDATE_MAKE, null);
context.commit(storeMutations.UPDATE_MODEL, null); context.commit(storeMutations.UPDATE_MODEL, null);
context.commit(storeMutations.UPDATE_STYLE, 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_URL, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); 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 year //Save new values
state.order.vehicle.year = year; context.commit(storeMutations.UPDATE_YEAR, year);
}, },
saveVehicleMake(context, make){ saveVehicleMake(context, make) {
//If new make, reset state dependencies
if(state.order.vehicle.make !== make){ //Reset dependent state when changing
if (context.state.order.vehicle.make !== make) {
context.commit(storeMutations.UPDATE_MODEL, null); context.commit(storeMutations.UPDATE_MODEL, null);
context.commit(storeMutations.UPDATE_STYLE, null); context.commit(storeMutations.UPDATE_STYLE, null);
context.commit(storeMutations.UPDATE_CAR_ID, 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_VIF_NUMBER, null);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
// Invokes
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); 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 make
state.order.vehicle.make = make;
},
saveVehicleModel(context, model){
//If new model, reset state dependencies //Save new values
if (state.order.vehicle.make !== model) { 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_STYLE, null);
context.commit(storeMutations.UPDATE_CAR_ID, null); context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, 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_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_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){ saveVehicleStyle(context, style) {
//If new style, reset state dependencies
if(state.order.vehicle.style !== style){ //Reset dependent state when changing
if (context.state.order.vehicle.style !== style) {
context.commit(storeMutations.UPDATE_CAR_ID, null); context.commit(storeMutations.UPDATE_CAR_ID, null);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null); context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, null);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
@ -699,58 +725,112 @@ export const actions = {
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null);
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); 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; //Save new values
}, context.commit(storeMutations.UPDATE_STYLE, style);
saveVehicleDamage(context){ },
context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); saveVehicleDamage(context, { isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount }) {
},
saveVinLookup(context){ const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
//if cardId is different AND selected glass part is not available reset damage and dependeices const isGlassToReplaceTheSame = (context.state.order.damage.glassToReplace?.length === selectedGlassToReplace.length)
if(context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle){ && context.state.order.damage.glassToReplace
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); .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({ export default createStore({
@ -767,4 +847,4 @@ export default createStore({
}); });
// Private Functions // Private Functions