Merge branch 'develop' into feature/CSR-2130

This commit is contained in:
CarlNation 2024-07-23 11:47:06 -04:00
commit 3bf4e4e47a
31 changed files with 605 additions and 261 deletions

View file

@ -33,6 +33,9 @@ const queryStrings = {
SERVICE_ZIP: "servicezip",
EMAIL: "email",
IS_INSURANCE: "isinsurance",
VIN_SELECTION: "vinselection",
SERVICE_PACKAGE: "servicepackage",
NUMBER_OF_CHIPS: "numberofchips",
};
export { queryStrings };

View file

@ -96,7 +96,8 @@ const storeActions = {
CREATE_SUBMITTED_ORDER: "createSubmittedOrder",
RESET_SUBMITTED_ORDER: "resetSubmittedOrder",
RESET_IS_LEAD_GEN: "resetIsLeadGen",
RESET_LEADGEN_STATE: "resetLeadGenState",
CREATE_LEADGEN_STATE: "createLeadGenState",
};
export { storeActions };

View file

@ -88,6 +88,28 @@ const storeMutations = {
// EXPERIMENT MUTATIONS
UPDATE_EXPERIMENTS: "updateExperiments",
UPDATE_TRIGGERED_SITE_ENTRY: "updateTriggeredSiteEntry",
// LEADGEN MUTATIONS
UPDATE_LEAD_GEN_YEAR: "updateLeadGenYear",
UPDATE_LEAD_GEN_MAKE: "updateLeadGenMake",
UPDATE_LEAD_GEN_MODEL: "updateLeadGenModel",
UPDATE_LEAD_GEN_STYLE: "updateLeadGenStyle",
UPDATE_LEAD_GEN_IS_REPAIR: "updateLeadGenIsRepair",
UPDATE_LEAD_GEN_NUMBER_OF_CHIPS: "updateLeadGenNumberOfChips",
UPDATE_LEAD_GEN_DAMAGE_TYPE: "updateLeadGenDamageType",
UPDATE_LEAD_GEN_ZIP_CODE: "updateLeadGenZipCode",
UPDATE_LEAD_GEN_EMAIL_ADDRESS: "updateLeadGenEmailAddress",
UPDATE_LEAD_GEN_IS_INSURANCE: "updateLeadGenIsInsurance",
UPDATE_LEAD_GEN_VIN_SELECTION: "updateLeadGenVinSelection",
UPDATE_LEAD_GEN_SERVICE_PACKAGE: "updateLeadGenServicePackage",
//RESET LEADGEN MUTATIONS
RESET_LEADGEN_VEHICLE_STATE: "resetLeadGenVehicleState",
RESETL_EADGEN_DAMAGE_STATE: "resetLeadGenDamageState",
RESET_LEADGEN_ESTIMATE_STATE: "resetLeadGenEstimateState",
RESET_LEADGEN_SERVICEZIP_STATE: "resetLeadGenServiceZipState",
RESET_LEADGEN_QUOTE_STATE: "resetLeadGenQuoteState",
RESET_IS_LEADGEN: "resetIsLeadGen",
};
export { storeMutations };

View file

@ -0,0 +1,15 @@
export function getDisplayTextForDurationLength(durationMinimum, durationMaximum) {
const isLongAppointment = durationMaximum >= 120;
const isDurationRange = durationMinimum !== durationMaximum;
const adjustedMinimum = isLongAppointment ? durationMinimum / 60 : durationMinimum;
const adjustedMaximum = isLongAppointment ? durationMaximum / 60 : durationMaximum;
const durationText = isDurationRange
? `${adjustedMinimum} - ${adjustedMaximum}`
: adjustedMinimum;
const unitText = isLongAppointment ? "hours" : "minutes";
return `${durationText} ${unitText}`;
}

View file

@ -0,0 +1,24 @@
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
describe("damage-length-helper.js", () => {
it("Should return the expected duration for the appointment in hours", () => {
// Arrange / Act
const durationMinimum = 60;
const durationMaximum = 120;
const duration = getDisplayTextForDurationLength(durationMinimum, durationMaximum);
// Assert
expect(duration).toEqual("1 - 2 hours");
});
it("Should return the expected duration for the appointment in minutes", () => {
// Arrange / Act
const durationMinimum = 30;
const durationMaximum = 45;
const duration = getDisplayTextForDurationLength(durationMinimum, durationMaximum);
// Assert
expect(duration).toEqual("30 - 45 minutes");
});
});

View file

@ -230,6 +230,15 @@ export function getHighestFullySatisfiedTier(glassToReplace, availableLineItems,
return highestSatisfiedPackage;
}
export function getPackageNameByType(packageType) {
const package_names = {
glassonly: packageNames.TIER_ONE,
standard: packageNames.TIER_TWO,
premium: packageNames.TIER_THREE,
};
return package_names[packageType] || null;
}
function maxTier(tierA, tierB) {
if (tierA === packageNames.TIER_THREE || tierB === packageNames.TIER_THREE) {
return packageNames.TIER_THREE;

View file

@ -119,7 +119,7 @@ import { settleAllPromises } from "@/helpers/layout-helper";
import { storeActions } from "@/constants/store-actions";
import { routerParams } from "@/router/router-constants/router-params";
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -150,6 +150,10 @@ export default {
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
},
data() {

View file

@ -25,6 +25,8 @@ beforeEach(() => {
startTime: "09:00",
endTime: "10:00",
routeCode: "000",
jobMaxMinutes: "120",
jobMinMinutes: "60",
},
lineItems: {
glassParts: [
@ -360,6 +362,41 @@ describe("computed properties...", () => {
// Assert
expect(testValue).toEqual("test1,<br/> test, AZ 12345");
});
test("Appointment Duration should return text in expected format.", () => {
//Arrange
const { wrapper } = setupMocks({});
// Act
const testValue = wrapper.vm.AppointmentDuration;
// Assert
expect(testValue).toEqual("Duration: 1 - 2 hours");
});
test("Appointment Duration should return with correct duration values in expected format for hours.", () => {
//Arrange
store.getters.submittedOrder.schedule.jobMaxMinutes = 120;
store.getters.submittedOrder.schedule.jobMinMinutes = 60;
const { wrapper } = setupMocks({});
// Act
const testValue = wrapper.vm.AppointmentDuration;
// Assert
expect(testValue).toEqual("Duration: 1 - 2 hours");
});
test("Appointment Duration should return with correct duration values in expected format for minutes.", () => {
//Arrange
store.getters.submittedOrder.schedule.jobMaxMinutes = 45;
store.getters.submittedOrder.schedule.jobMinMinutes = 30;
const { wrapper } = setupMocks({});
// Act
const testValue = wrapper.vm.AppointmentDuration;
// Assert
expect(testValue).toEqual("Duration: 30 - 45 minutes");
});
});
function setupMocks({ customMountOptions }) {

View file

@ -42,6 +42,12 @@
:scheduleEndTime="ScheduleEndTime" />
<div class="appoinmenttext" v-html="AppointmentWordingText"></div>
<textBlock
:customText="AppointmentDuration"
justifyText="center"
typeStyle="medium"
class="duration-text-block" />
</div>
<hr />
@ -82,6 +88,7 @@ import vehicleBanner from "@/fmg-components/vehicle-banner/vehicle-banner";
import navbar from "@/fmg-components/nav-bar/nav-bar";
import addToCalendar from "@/layouts/confirmation/add-to-calendar/add-to-calendar";
import cart from "@/fmg-components/cart/cart";
import textBlock from "@/digital-components/text-block/text-block";
//Supporting files
import baseMixin from "@/mixins/base-mixin.js";
@ -97,6 +104,7 @@ import { deepClone } from "@/helpers/object-helper";
import { Form } from "vee-validate";
import { get12HourTimeFormat, get12HourTimeMobileFormat } from "@/helpers/date-helper";
import { coverageStatus } from "@/constants/insurance";
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
export default {
name: "confirmation",
@ -315,6 +323,11 @@ export default {
isPia() {
return store.getters.submittedOrder?.payment.isPia;
},
AppointmentDuration() {
const durationMaximum = store.getters.submittedOrder?.schedule?.jobMaxMinutes;
const durationMinimum = store.getters.submittedOrder?.schedule?.jobMinMinutes;
return "Duration: " + getDisplayTextForDurationLength(durationMinimum, durationMaximum);
},
},
methods: {
arePagePrerequisitesValid() {
@ -365,6 +378,7 @@ export default {
vehicleBanner,
addToCalendar,
cart,
textBlock,
},
};
</script>

View file

@ -12,6 +12,7 @@ import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import baseMixin from "../../mixins/base-mixin";
import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js";
import { experimentSettings } from "@/constants/experiments";
import { nextTick } from "vue";
// Mock our module for promises.
jest.mock("@/helpers/layout-helper.js", () => ({
@ -213,20 +214,18 @@ describe("estimate.vue", () => {
});
describe("estimate.vue", () => {
test("should call forwardButtonAction if isLeadGen is true", async () => {
// update store with isLeadGen as true
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
store.commit(storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION, "decline");
// Set up the component
const { wrapper } = setupMocks({});
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set selectedVinLookupMethod to decline
wrapper.setData({ selectedVinLookupMethod: vinLookupMethodSelections.DECLINE });
// Call the method that contains the if-else logic
await estimate.beforeRouteEnter.call(
wrapper.vm,
@ -234,7 +233,12 @@ describe("estimate.vue", () => {
undefined,
nextFunction
);
await wrapper.vm.$nextTick();
expect(nextFunction).toHaveBeenCalled();
expect(baseMixin.methods.isFormValid).toHaveBeenCalled();
expect(baseMixin.methods.isFormValid()).toBe(true);
await wrapper.vm.$nextTick();
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
});
});
@ -247,6 +251,7 @@ function setupMocks({
{ Name: "Provide my VIN manually Most specific to your vehicle" },
{ Name: "Provide my license plate # Most accurate VIN match" },
{ Name: "Provide my home address Most convenient VIN match" },
{ Name: "I'd rather not share my VIN" },
],
FunnelFooterWidget = { ForwardButtonText: "test txt" },
mountOptionsMockData = {
@ -280,7 +285,7 @@ function setupMocks({
const apiPromise = Promise.resolve({ cmsContent });
settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const mountOptions = getMountOptions({
...mountOptionsMockData,
mixins: [baseMixin, mockMixin],

View file

@ -63,6 +63,7 @@ import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigat
import { saveSession } from "@/helpers/heritage-integration/order-helper.js";
import baseMixin from "@/mixins/base-mixin.js";
import { queryStrings } from "@/constants/query-strings";
import { nextTick } from "vue";
// Define Validation Rules
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
@ -128,7 +129,7 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap);
next((vm) => {
next(async (vm) => {
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) {
const forwardTextOption =
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
@ -146,10 +147,24 @@ export default {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
vm.selectedVinLookupMethod = vinLookupMethodSelections.DECLINE;
vm.forwardButtonAction();
if (store.getters.leadGenEstimate.vinSelection) {
vm.selectedVinLookupMethod = vinPagesMixin.methods.getVinlookupMethod(
store.getters.leadGenEstimate.vinSelection
);
await nextTick();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction();
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});

View file

@ -77,7 +77,7 @@ export default {
vm.setCmsContent(resultMap.cmsContent);
vm.originalList = resultMap.insuranceCompanyList;
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});

View file

@ -112,7 +112,7 @@ import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-help
import { routerParams } from "@/router/router-constants/router-params";
import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate";
import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -148,6 +148,10 @@ export default {
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
},
props: {

View file

@ -56,7 +56,7 @@ export default {
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});

View file

@ -58,6 +58,9 @@ jest.mock("@/mixins/base-mixin", () => ({
filterOutFees(items) {
return null;
},
isFormValid(form) {
return true;
},
},
}));
@ -66,6 +69,9 @@ const mockMixin = {
filterOutFees: jest.fn().mockImplementation(() => {
return null;
}),
isFormValid: jest.fn().mockImplementation(() => {
return true;
}),
getSettingValue: jest.fn((settingName) => {
if (settingName === experimentSettings.SERVICE_PACKAGE_DISCOUNT) {
return true;
@ -641,7 +647,7 @@ describe("quote.vue", () => {
});
});
describe("quote.vue", () => {
test("should call forwardButtonAction if isLeadGen is true and Insurance is true", async () => {
test("should call forwardButtonAction if isLeadGen and Insurance is true and form is valid", async () => {
// Set up the store with isLeadGen as true
store.getters = {
@ -666,6 +672,10 @@ describe("quote.vue", () => {
},
},
isLeadGen: true,
leadGenQuote: {
isInsurance: true,
servicePackage: "glassonly",
},
payment: {
isInsurance: true,
inactivePromos: [],
@ -693,72 +703,24 @@ describe("quote.vue", () => {
undefined,
nextFunction
);
await nextTick();
expect(nextFunction).toHaveBeenCalled();
expect(baseMixin.methods.isFormValid).toHaveBeenCalled();
expect(baseMixin.methods.isFormValid()).toBe(true);
await wrapper.vm.$nextTick();
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
});
test("should not call forwardButtonAction if isLeadGen is true and Insurance is false", async () => {
// Set up the store with isLeadGen as true
store.getters = {
lineItems: {
glassParts: ["item", "item2"],
},
order: {
lineItems: {
glassParts: ["item", "item2"],
},
serviceLocation: {
zipCode: "12345",
zipCodeCtu: "value",
},
damage: {
isRepair: false,
},
referralNumber: "1234567",
payment: {
isInsurance: null,
inactivePromos: [],
},
},
isLeadGen: true,
payment: {
isInsurance: null,
inactivePromos: [],
},
vehicle: {
cardId: "123",
},
experimentSettings: {
settingName: "SERVICE_PACKAGE_DISCOUNT",
},
};
// Set up the component
const { wrapper } = setupMocks({});
wrapper.vm.$route = { query: null };
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Call the method that contains the if-else logic
await quote.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "quote" } },
undefined,
nextFunction
);
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
});
});
function setupMocks({ customMountOptions }) {
const mountOptions = getMountOptions({
...customMountOptions,
});
baseMixin.methods.hideFmgLoadingModal = jest.fn();
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
mountOptions.global.mocks["$store"] = store;
mountOptions["attachTo"] = document.body;
const wrapper = shallowMount(quote, mountOptions);
wrapper.vm.setCmsContent = jest.fn();
return { wrapper };

View file

@ -33,6 +33,7 @@
:isInsuranceSelected="isInsuranceSelected"
@vapsItemsSelected="vapsItemsSelectedAction"
@servicePackageDiscountSelected="servicePackageDiscountSelectedAction"
:servicePackage="servicePackage"
:activePromos="lineItems.promos"
v-on="{ 'buttonEvent.openModal': openModalAction }"
validationRules="option-required"
@ -124,6 +125,7 @@ import promoModalQuestion from "@/fmg-components/promo-modal-question/promo-moda
import { experimentSettings } from "@/constants/experiments";
import { partTypeStrings } from "@/constants/part-type-strings";
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
import { nextTick } from "vue";
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
export default {
@ -245,7 +247,7 @@ export default {
// End of promo logic
// Call the "next" function to complete the transition to this page.
next((vm) => {
next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.addableVaps = addableVaps;
vm.lineItems = lineItems;
@ -271,14 +273,23 @@ export default {
);
}
if (store.getters.isLeadGen) {
if (store.getters.order.payment.isInsurance == true) {
vm.forwardButtonAction();
if (store.getters.leadGenQuote.isInsurance == true) {
vm.isInsuranceSelected = true;
vm.servicePackage = store.getters.leadGenQuote.servicePackage;
await nextTick();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction();
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
@ -289,6 +300,7 @@ export default {
availableLineItems: null,
lineItems: [],
addableVaps: [],
servicePackage: null,
};
},
computed: {
@ -454,7 +466,12 @@ export default {
},
};
</script>
<style scoped>
<style>
.funnel-sub-header {
p {
font-size: 1rem;
}
}
.text-block {
display: block;
}

View file

@ -28,6 +28,7 @@ import {
getPackageContents,
containsLineItemWithPartType,
findLineItemsWithPartType,
getPackageNameByType,
} from "@/helpers/service-package-helper";
import {
getPromosThatMatchLineItemsOnOrder,
@ -47,6 +48,7 @@ export default {
isInsuranceSelected: Boolean,
availableLineItems: null,
activePromos: null,
servicePackage: null,
},
data() {
return {
@ -58,7 +60,8 @@ export default {
availableLineItems() {
if (
this.$store.getters.payment.isInsurance != null ||
getPromosWithAddableVaps(this.activePromos).length
getPromosWithAddableVaps(this.activePromos).length ||
this.servicePackage != null
) {
this.selectDefaultPackage();
}
@ -293,6 +296,9 @@ export default {
return price;
},
selectDefaultPackage() {
if (this.servicePackage != null) {
return (this.selectedPackageName = getPackageNameByType(this.servicePackage));
}
const promosWithAddableVaps = getPromosWithAddableVaps(this.activePromos);
const vapsThatMatchPromos = getLineItemsThatMatchPromos(
promosWithAddableVaps,

View file

@ -38,7 +38,7 @@
class="strikethrough-price"
v-if="shouldDisplayStrikeThroughPrice"
v-html="this.additionalButtonData.strikeThroughPrice"></span>
<span v-html="this.buttonAuxillaryCopy"></span>*
<span v-html="this.buttonAuxillaryCopy"></span>
</span>
</p>
<p
@ -150,9 +150,11 @@ export default {
display: block;
@include media-breakpoint-up(md) {
display: flex;
min-height: 320px;
min-height: 336px;
}
@include media-breakpoint-up(xl) {
//Unique breakpoint for this page only to accommodate price spacing issues
//from use of position: absolute on .service-package-discount (per Design Team request)
@media only screen and (min-width: 860px) {
display: flex;
min-height: 276px;
}
@ -336,7 +338,6 @@ export default {
margin: 1rem 0 0 -15px;
padding: 0;
li {
margin-bottom: 0.5rem;
font-size: 0.875rem;
line-height: 1.714;
color: $gray-550;

View file

@ -60,19 +60,3 @@ export function militaryToTwelveHourTime(timeString) {
return `${hours}:${minutes} ${meridianNotation}`;
}
export function getDisplayTextForDurationLength(durationMinimum, durationMaximum) {
const isLongAppointment = durationMaximum >= 120;
const isDurationRange = durationMinimum !== durationMaximum;
const adjustedMinimum = isLongAppointment ? durationMinimum / 60 : durationMinimum;
const adjustedMaximum = isLongAppointment ? durationMaximum / 60 : durationMaximum;
const durationText = isDurationRange
? `${adjustedMinimum} - ${adjustedMaximum}`
: adjustedMinimum;
const unitText = isLongAppointment ? "hours" : "minutes";
return `${durationText} ${unitText}`;
}

View file

@ -51,8 +51,8 @@ import { deepClone } from "@/helpers/object-helper";
import {
convertDateStringToDate,
militaryToTwelveHourTime,
getDisplayTextForDurationLength,
} from "@/layouts/schedule/helpers/schedule-helper";
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
// Validation - TODO: Move this somewhere more global?
import { defineRule, useField } from "vee-validate";

View file

@ -165,6 +165,10 @@ function resetMockStoreData() {
jobMaxMinutes: null,
jobMinMinutes: null,
},
leadGenServiceZip: {
zipCode: null,
emailAddress: null,
},
};
}
@ -175,6 +179,7 @@ function applyMockStoreDataToGetters() {
damage: mockStoreData.damage,
payment: mockStoreData.payment,
policy: mockStoreData.policy,
leadGenServiceZip: mockStoreData.leadGenServiceZip,
};
store.state.order = mockStoreData;
store.state.applicationUser.experiments = mockExperimentSettings;
@ -416,9 +421,7 @@ describe("service-zip.vue", () => {
});
// Mock the isFormValid method
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => {
return true;
});
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
// Call the method that contains the if-else logic
await serviceZip.beforeRouteEnter.call(
@ -442,7 +445,7 @@ describe("service-zip.vue", () => {
});
// Mock the isFormValid method
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => {
baseMixin.methods.isFormValid = jest.fn().mockImplementation(() => {
return false;
});
@ -463,6 +466,7 @@ function setupMocks({ customMountOptions, customZipQuery, customZipDataResponse
route.query.zipcode = customZipQuery;
}
baseMixin.methods.hideFmgLoadingModal = jest.fn();
const mountOptions = getMountOptions({
...customMountOptions,
route: route,

View file

@ -134,11 +134,11 @@ export default {
next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
const isValid = await vm.isFormValid();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction();
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
}
@ -146,10 +146,16 @@ export default {
},
methods: {
getZipFromStore() {
return store.getters.order.serviceLocation.zipCode;
return (
store.getters.leadGenServiceZip.zipCode ??
store.getters.order.serviceLocation.zipCode
);
},
getEmailFromStore() {
return store.getters.order.customer.emailAddress;
return (
store.getters.leadGenServiceZip.emailAddress ??
store.getters.order.customer.emailAddress
);
},
arePagePrerequisitesValid() {
return store.getters.damage.isRepair || store.getters.damage.glassToReplace?.length > 0;
@ -185,7 +191,7 @@ export default {
if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true;
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
return this.$refs.navbar.removeLoader();
@ -195,7 +201,7 @@ export default {
if (!zipCodeData.isServiceable) {
this.displayNonServiceableZipAlert = true;
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
return this.$refs.navbar.removeLoader();
@ -250,11 +256,6 @@ export default {
await this.navigateForwardWithSingleCarMatch();
}
},
async isFormValid() {
const form = this.$refs.theForm;
const formValidateResponse = await form.validate();
return formValidateResponse?.valid;
},
},
computed: {
AlertNonServiceableZipHeader() {

View file

@ -67,6 +67,11 @@ jest.mock("@/store", () => ({
},
},
isLeadGen: false,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
},
}));
@ -148,6 +153,11 @@ describe("vehicle-damage.vue", () => {
getters: {
vehicle: {},
payment: { insuranceCoverage: { isVerified: false } },
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
},
},
},
@ -183,6 +193,7 @@ describe("vehicle-damage.vue", () => {
(c) => c(wrapper.vm)
);
wrapper.vm.isFormValid = jest.fn();
await wrapper.vm.forwardButtonAction();
//Assert
@ -257,6 +268,11 @@ describe("vehicle-damage.vue", () => {
getters: {
vehicle: {},
payment: { insuranceCoverage: { isVerified: false } },
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
},
},
},
@ -278,7 +294,7 @@ describe("vehicle-damage.vue", () => {
undefined,
(c) => c(wrapper.vm)
);
wrapper.vm.isFormValid = jest.fn();
await wrapper.vm.forwardButtonAction();
//Assert
@ -540,6 +556,11 @@ describe("vehicle-damage.vue", () => {
eventBusItem: jest.fn(),
damage: { glassToReplace: [{ glassLocation: damageLocation }] },
isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
};
var glassSelections = wrapper.vm.getDamageLocationsFromStore();
@ -617,6 +638,11 @@ describe("vehicle-damage.vue", () => {
isRepair: isRepair,
numberOfChips: 2,
},
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
};
var windshieldSelections = wrapper.vm.getWindshieldOptionsFromStore();
@ -653,6 +679,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
},
isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
};
var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore();
@ -689,6 +720,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
},
isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
};
var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore();
@ -723,6 +759,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
},
isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
};
var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore();
@ -744,6 +785,11 @@ describe("vehicle-damage.vue", () => {
vehicle: {},
payment: { insuranceCoverage: { isVerified: true } },
requiresVerifiedRedirecting: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
},
},
},
@ -763,20 +809,24 @@ describe("vehicle-damage.vue", () => {
});
describe("vehicle-damage.vue", () => {
test("should call forwardButtonAction if isLeadGen is true and selectedDamageLocations is not empty", async () => {
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
// Set up the store with isLeadGen as true
store.getters.isLeadGen = true;
store.getters.leadGenDamage = {
damageType: "windshieldReplace",
isRepair: false,
numberOfChips: null,
};
// Set up the component
const { wrapper } = setupMocks({});
wrapper.vm.forwardButtonAction = jest.fn();
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set selectedDamageLocations
wrapper.setData({ selectedDamageLocations: ["windshield"] });
// Call the method that contains the if-else logic
await vehicleDamage.beforeRouteEnter.call(
wrapper.vm,
@ -784,32 +834,10 @@ describe("vehicle-damage.vue", () => {
undefined,
nextFunction
);
await nextTick();
expect(nextFunction).toHaveBeenCalled();
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
});
test("should not call forwardButtonAction if isLeadGen is true and selectedDamageLocations is empty", async () => {
// Set up the store with isLeadGen as true
store.getters.isLeadGen = true;
// Set up the component
const { wrapper } = setupMocks({});
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set selectedDamageLocations to empty
wrapper.setData({ selectedDamageLocations: [] });
// Call the method that contains the if-else logic
await vehicleDamage.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "vehicle-damage" } },
undefined,
nextFunction
);
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
});
});
});
@ -834,7 +862,12 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo
isVerified: false,
},
},
isLeadGen: false,
// isLeadGen: false,
// leadGenDamage: {
// damageType: null,
// isRepair: null,
// numberOfChips: null,
// },
},
},
};

View file

@ -106,6 +106,7 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import store from "@/store";
import baseMixin from "@/mixins/base-mixin";
import { nextTick } from "vue";
// DEFINE VALIDATION RULES
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
@ -136,7 +137,7 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page.
next((vm) => {
next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions);
vm.$refs.sideDoorOptions.initializeComponent(
@ -150,14 +151,16 @@ export default {
resultMap.damageOptions.backGlassOptions.availableReplacementOptions
);
if (store.getters.isLeadGen) {
if (vm.selectedDamageLocations?.length > 0) {
await nextTick();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction();
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
@ -184,7 +187,6 @@ export default {
}
return false;
},
attachCustomEvents() {
if (this.$store.getters.vehicle.imageVifNumber) {
this.pushEventToGA(
@ -208,7 +210,9 @@ export default {
store.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.WINDSHIELD;
}) ||
store.getters.damage.isRepair
store.getters.damage.isRepair ||
store.getters.leadGenDamage.isRepair ||
store.getters.leadGenDamage.damageType?.toUpperCase().includes("WINDSHIELD")
) {
glassSelections.push(damageLocationsSelected.WINDSHIELD);
}
@ -241,11 +245,16 @@ export default {
selectedWindshieldReplaceOptions: [],
};
if (store.getters.damage.isRepair === undefined) return windshieldOptions;
if (
store.getters.leadGenDamage.isRepair === undefined ||
store.getters.damage.isRepair === undefined
)
return windshieldOptions;
if (store.getters.damage.isRepair) {
if (store.getters.leadGenDamage.isRepair || store.getters.damage.isRepair) {
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
windShieldOptions.selectedWindshieldChipCount = store.getters.damage.numberOfChips;
windShieldOptions.selectedWindshieldChipCount =
store.getters.leadGenDamage.numberOfChips || store.getters.damage.numberOfChips;
} else {
if (
store.getters.damage.glassToReplace?.some((glass) => {
@ -253,7 +262,8 @@ export default {
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.glassName === damageLocationsSelected.SINGLE
);
})
}) ||
store.getters.leadGenDamage.damageType?.toUpperCase() === "WINDSHIELDREPLACE"
) {
windShieldOptions.selectedWindshieldDamageType =
damageLocationsSelected.REPLACE;
@ -350,6 +360,8 @@ export default {
},
async forwardButtonAction() {
const isValid = await this.isFormValid();
console.log(isValid);
await this.dispatchStoreAction(
this.storeActions.SAVE_VEHICLE_DAMAGE,
{

View file

@ -29,6 +29,12 @@ jest.mock("@/store", () => ({
experiments: [{ universeName: "ConceptFunnel" }],
},
isLeadGen: false,
leadGenVehicle: {
year: null,
make: null,
model: null,
style: null,
},
vehicle: {
carId: "C00000000",
image: "test.jpg",
@ -87,50 +93,21 @@ describe("vehicle.vue", () => {
});
describe("vehicle.vue", () => {
test("should call forwardButtonAction if isLeadGen is true and displayNoServiceAlert is false", async () => {
// Set up the store with isLeadGen as true
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
store.getters.isLeadGen = true;
// Set up the component
// Create a shallow mount of MyComponent
const { wrapper } = setupMocks();
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set displayNoServiceAlert to false
wrapper.setData({ displayNoServiceAlert: false });
// Mock the getVehicleDetails method
wrapper.vm.getVehicleDetails = jest.fn();
// Call the method that contains the if-else logic
await vehicle.beforeRouteEnter.call(
wrapper.vm,
{ query: { fmgPage: "vehicle" } },
undefined,
nextFunction
);
expect(nextFunction).toHaveBeenCalled();
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
});
test("should not call forwardButtonAction if isLeadGen is true and displayNoServiceAlert is true", async () => {
// Set up the store with isLeadGen as true
store.getters.isLeadGen = true;
// Set up the component
const { wrapper } = setupMocks();
wrapper.vm.forwardButtonAction = jest.fn();
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set displayNoServiceAlert to false
wrapper.setData({ displayNoServiceAlert: true });
// Mock the getVehicleDetails method
wrapper.vm.getVehicleDetails = jest.fn();
// Call the method that contains the if-else logic
await vehicle.beforeRouteEnter.call(
wrapper.vm,
@ -138,7 +115,10 @@ describe("vehicle.vue", () => {
undefined,
nextFunction
);
expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled();
await nextTick();
expect(nextFunction).toHaveBeenCalled();
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
});
});

View file

@ -143,14 +143,14 @@ export default {
var styleQuestionInitialDataPromise = null;
if (
store.getters.order.vehicle.make &&
store.getters.order.vehicle.model &&
store.getters.order.vehicle.style
(store.getters.leadGenVehicle.make || store.getters.order.vehicle.make) &&
(store.getters.leadGenVehicle.model || store.getters.order.vehicle.model) &&
(store.getters.leadGenVehicle.style || store.getters.order.vehicle.style)
) {
makeQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_MAKES,
{
year: store.getters.order.vehicle.year,
year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
},
"vehicle"
);
@ -158,8 +158,8 @@ export default {
modelQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_MODELS,
{
year: store.getters.order.vehicle.year,
make: store.getters.order.vehicle.make,
year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
make: store.getters.leadGenVehicle.make || store.getters.order.vehicle.make,
},
"vehicle"
);
@ -167,9 +167,9 @@ export default {
styleQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_STYLES,
{
year: store.getters.order.vehicle.year,
make: store.getters.order.vehicle.make,
model: store.getters.order.vehicle.model,
year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
make: store.getters.leadGenVehicle.make || store.getters.order.vehicle.make,
model: store.getters.leadGenVehicle.model || store.getters.order.vehicle.model,
},
"vehicle"
);
@ -235,13 +235,19 @@ export default {
if (store.getters.isLeadGen) {
await vm.getVehicleDetails();
if (!vm.displayNoServiceAlert) {
vm.forwardButtonAction();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction();
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
} else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN);
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
@ -429,16 +435,16 @@ export default {
this.styleOptions = styleOptions;
},
selectedYearfromStore() {
return store.getters.vehicle.year?.toString();
return store.getters.leadGenVehicle.year ?? store.getters.vehicle.year?.toString();
},
selectedMakefromStore() {
return store.getters.vehicle.make;
return store.getters.leadGenVehicle.make ?? store.getters.vehicle.make;
},
selectedModelfromStore() {
return store.getters.vehicle.model;
return store.getters.leadGenVehicle.model ?? store.getters.vehicle.model;
},
selectedStylefromStore() {
return store.getters.vehicle.style;
return store.getters.leadGenVehicle.style ?? store.getters.vehicle.style;
},
async getMakeOptions(year) {
return await baseMixin.methods.dispatchStoreActionWithLogging(

View file

@ -154,7 +154,7 @@ 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 baseMixin from "@/mixins/base-mixin.js";
import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -192,6 +192,10 @@ export default {
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
});
},
data() {

View file

@ -196,6 +196,10 @@ export default {
hideFmgLoadingModal() {
showFmgLoadingModal(false);
},
async isFormValid(form) {
const formValidateResponse = await form?.validate();
return formValidateResponse?.valid;
},
showApplePay() {
if (window.ApplePaySession && window.ApplePaySession.canMakePayments()) {
var iOSversion = this.getiOSversion();

View file

@ -3,6 +3,7 @@ import store from "@/store";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { saveSession } from "@/helpers/heritage-integration/order-helper.js";
import { experimentSettings } from "@/constants/experiments";
import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js";
export default {
computed: {
@ -32,5 +33,14 @@ export default {
vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this);
},
getVinlookupMethod(vinSelection) {
const vinLookupMethods = {
vin: vinLookupMethodSelections.MANUALVIN,
licensePlate: vinLookupMethodSelections.LICENSEPLATE,
address: vinLookupMethodSelections.HOMEADDRESS,
decline: vinLookupMethodSelections.DECLINE,
};
return vinLookupMethods[vinSelection] || null;
},
},
};

View file

@ -33,6 +33,7 @@ import { experimentTriggers } from "../constants/experiments";
import { applicationConfig } from "../constants/application-config";
import { shouldStripPromoQueryString } from "@/helpers/promotions-helper";
import bailout from "@/layouts/bailout/bailout";
import { nextTick } from "vue";
const routes = [
{
@ -84,14 +85,25 @@ const routes = [
);
const parentAccount = getQuerystringParameter(queryStrings.PARENT_ACCOUNT);
const correlationId = getQuerystringParameter(queryStrings.CORRELATION_ID);
const vehicleYear = getQuerystringParameter(queryStrings.VEHICLE_YEAR);
const vehicleMake = getQuerystringParameter(queryStrings.VEHICLE_MAKE);
const vehicleModel = getQuerystringParameter(queryStrings.VEHICLE_MODEL);
const vehicleStyle = getQuerystringParameter(queryStrings.VEHICLE_STYLE);
const vehicleDamage = getQuerystringParameter(queryStrings.VEHICLE_DAMAGE);
const serviceZip = getQuerystringParameter(queryStrings.SERVICE_ZIP);
const email = getQuerystringParameter(queryStrings.EMAIL);
const isInsurance = getQuerystringParameter(queryStrings.IS_INSURANCE);
const leadGenYear = getQuerystringParameter(queryStrings.VEHICLE_YEAR);
const leadGenMake = getQuerystringParameter(queryStrings.VEHICLE_MAKE);
const leadGenModel = getQuerystringParameter(queryStrings.VEHICLE_MODEL);
const leadGenStyle = getQuerystringParameter(queryStrings.VEHICLE_STYLE);
const leadGenDamage = getQuerystringParameter(queryStrings.VEHICLE_DAMAGE);
const leadGenZipCode = getQuerystringParameter(queryStrings.SERVICE_ZIP);
const leadGenEmail = getQuerystringParameter(queryStrings.EMAIL);
const leadGenIsInsurance = getQuerystringParameter(
queryStrings.IS_INSURANCE
);
const leadGenVinSelection = getQuerystringParameter(
queryStrings.VIN_SELECTION
);
const leadGenServicePackage = getQuerystringParameter(
queryStrings.SERVICE_PACKAGE
);
const leadGenNumberOfChips = getQuerystringParameter(
queryStrings.NUMBER_OF_CHIPS
);
if (referralNumber) {
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
store.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccount);
@ -102,46 +114,63 @@ const routes = [
updateOrCreateFunnelCookie();
}
if (
vehicleYear &&
vehicleMake &&
vehicleModel &&
vehicleStyle &&
vehicleDamage &&
serviceZip &&
email &&
isInsurance
leadGenYear &&
leadGenMake &&
leadGenModel &&
leadGenStyle &&
leadGenDamage &&
leadGenZipCode &&
leadGenEmail &&
leadGenIsInsurance &&
(leadGenDamage.toUpperCase() == "WINDSHIELDREPAIR" ||
leadGenVinSelection?.length > 0) &&
(leadGenIsInsurance == "false" || leadGenServicePackage?.length > 0) &&
(leadGenDamage.toUpperCase() != "WINDSHIELDREPAIR" ||
leadGenNumberOfChips?.length > 0)
) {
if (!store.getters.applicationUser.triggeredSiteEntry) {
store.commit(storeMutations.UPDATE_YEAR, vehicleYear);
store.commit(storeMutations.UPDATE_MAKE, vehicleMake);
store.commit(storeMutations.UPDATE_MODEL, vehicleModel);
store.commit(storeMutations.UPDATE_STYLE, vehicleStyle);
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
if (vehicleDamage == "windshieldReplace") {
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, null);
const glassToReplace = [
{ glassLocation: "Windshield", glassName: "Single" },
];
store.commit(storeMutations.UPDATE_LEAD_GEN_YEAR, leadGenYear);
store.commit(storeMutations.UPDATE_LEAD_GEN_MAKE, leadGenMake);
store.commit(storeMutations.UPDATE_LEAD_GEN_MODEL, leadGenModel);
store.commit(storeMutations.UPDATE_LEAD_GEN_STYLE, leadGenStyle);
store.commit(
storeMutations.UPDATE_LEAD_GEN_DAMAGE_TYPE,
leadGenDamage
);
if (leadGenDamage.toUpperCase() == "WINDSHIELDREPLACE") {
store.commit(storeMutations.UPDATE_LEAD_GEN_IS_REPAIR, false);
store.commit(
storeMutations.UPDATE_GLASS_TO_REPLACE,
glassToReplace
storeMutations.UPDATE_LEAD_GEN_NUMBER_OF_CHIPS,
null
);
} else if (leadGenDamage.toUpperCase() == "WINDSHIELDREPAIR") {
store.commit(storeMutations.UPDATE_LEAD_GEN_IS_REPAIR, true);
store.commit(
storeMutations.UPDATE_LEAD_GEN_NUMBER_OF_CHIPS,
leadGenNumberOfChips
);
} else if (vehicleDamage == "windshieldRepair") {
store.commit(storeMutations.UPDATE_IS_REPAIR, true);
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, 1);
}
const serviceZipInfo = {
state: null,
zipCode: serviceZip,
zipCodeCtu: null,
};
store.commit(storeMutations.UPDATE_SERVICE_ZIP, serviceZipInfo);
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email);
if (isInsurance == "true") {
store.commit(storeMutations.UPDATE_IS_INSURANCE, true);
} else {
store.commit(storeMutations.UPDATE_IS_INSURANCE, null);
store.commit(
storeMutations.UPDATE_LEAD_GEN_ZIP_CODE,
leadGenZipCode
);
store.commit(
storeMutations.UPDATE_LEAD_GEN_EMAIL_ADDRESS,
leadGenEmail
);
if (leadGenIsInsurance == "true") {
store.commit(storeMutations.UPDATE_LEAD_GEN_IS_INSURANCE, true);
store.commit(
storeMutations.UPDATE_LEAD_GEN_SERVICE_PACKAGE,
leadGenServicePackage
);
}
if (leadGenDamage.toUpperCase() != "WINDSHIELDREPAIR") {
store.commit(
storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION,
leadGenVinSelection
);
}
}
}

View file

@ -24,8 +24,8 @@ import { partTypeStrings } from "@/constants/part-type-strings";
import {
convertDateStringToDate,
militaryToTwelveHourTime,
getDisplayTextForDurationLength,
} from "@/layouts/schedule/helpers/schedule-helper";
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
import { paymentMethods } from "@/constants/payment-method-constants";
import {
getPromoCodeWithoutBundleIdentifier,
@ -160,7 +160,6 @@ const getDefaultState = () => {
customerPortalLoginToken: null,
lockToken: null,
settledTenderAmount: 0,
isLeadGen: false,
},
applicationUser: {
eventBus: [],
@ -177,7 +176,7 @@ const getDefaultState = () => {
};
export const state = getDefaultState();
export const leadGenState = getLeadGenDefaultState();
// Export Mutations
export const mutations = {
// VEHICLE MUTATIONS
@ -295,9 +294,6 @@ export const mutations = {
updateSettledTenderAmount(state, settledTenderAmount) {
state.order.settledTenderAmount = settledTenderAmount;
},
updateIsLeadGen(state, isLeadGen) {
state.order.isLeadGen = isLeadGen;
},
updateCCToken(state, ccToken) {
state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId;
state.order.payment.ccToken.expMonth = ccToken.expMonth;
@ -418,6 +414,92 @@ export const mutations = {
state.applicationUser.eventBus.splice(itemIndex, 1);
}
},
//LEADGEN MUTATIONS
updateIsLeadGen(state, isLeadGen) {
leadGenState.isLeadGen = isLeadGen;
setLeadGenState(leadGenState);
},
updateLeadGenYear(state, year) {
leadGenState.vehicle.year = year;
setLeadGenState(leadGenState);
},
updateLeadGenMake(state, make) {
leadGenState.vehicle.make = make;
setLeadGenState(leadGenState);
},
updateLeadGenModel(state, model) {
leadGenState.vehicle.model = model;
setLeadGenState(leadGenState);
},
updateLeadGenStyle(state, style) {
leadGenState.vehicle.style = style;
setLeadGenState(leadGenState);
},
updateLeadGenIsRepair(state, isRepair) {
leadGenState.vehicleDamage.isRepair = isRepair;
setLeadGenState(leadGenState);
},
updateLeadGenNumberOfChips(state, numberOfChips) {
leadGenState.vehicleDamage.numberOfChips = numberOfChips;
setLeadGenState(leadGenState);
},
updateLeadGenDamageType(state, damageType) {
leadGenState.vehicleDamage.damageType = damageType;
setLeadGenState(leadGenState);
},
updateLeadGenZipCode(state, zipCode) {
leadGenState.serviceZip.zipCode = zipCode;
setLeadGenState(leadGenState);
},
updateLeadGenEmailAddress(state, emailAddress) {
leadGenState.serviceZip.emailAddress = emailAddress;
setLeadGenState(leadGenState);
},
updateLeadGenIsInsurance(state, isInsurance) {
leadGenState.quote.isInsurance = isInsurance;
setLeadGenState(leadGenState);
},
updateLeadGenVinSelection(state, vinSelection) {
leadGenState.estimate.vinSelection = vinSelection;
setLeadGenState(leadGenState);
},
updateLeadGenServicePackage(state, servicePackage) {
leadGenState.quote.servicePackage = servicePackage;
setLeadGenState(leadGenState);
},
//RESET LEADGEN MUTATIONS
resetLeadGenVehicleState(state) {
leadGenState.vehicle.year =
leadGenState.vehicle.make =
leadGenState.vehicle.model =
leadGenState.vehicle.style =
null;
setLeadGenState(leadGenState);
},
resetLeadGenDamageState(state) {
leadGenState.vehicleDamage.isRepair =
leadGenState.vehicleDamage.numberOfChips =
leadGenState.vehicleDamage.damageType =
null;
setLeadGenState(leadGenState);
},
resetLeadGenEstimateState(state) {
leadGenState.estimate.vinSelection = null;
setLeadGenState(leadGenState);
},
resetLeadGenServiceZipState(state) {
leadGenState.serviceZip.zipCode = leadGenState.serviceZip.emailAddress = null;
setLeadGenState(leadGenState);
},
resetLeadGenQuoteState(state) {
leadGenState.quote.isInsurance = null;
leadGenState.quote.servicePackage = null;
setLeadGenState(leadGenState);
},
resetIsLeadGen(state) {
leadGenState.isLeadGen = null;
setLeadGenState(leadGenState);
},
// RESET DEPENDENCY MUTATIONS
resetVehicleState(state) {
@ -678,7 +760,6 @@ export const getters = {
isOvernightDropOffAppointment: (state) => {
return state.order.schedule.routeCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF);
},
isLeadGen: (state) => state.order.isLeadGen,
isRecalibrationOnOrder: (state) => {
return getHasRecalibrationPart(state);
},
@ -809,6 +890,12 @@ export const getters = {
requiresVerifiedRedirecting: (state) => {
return state.order?.referralNumber?.length === 6;
},
isLeadGen: (state) => leadGenState?.isLeadGen,
leadGenVehicle: (state) => leadGenState?.vehicle,
leadGenDamage: (state) => leadGenState?.vehicleDamage,
leadGenQuote: (state) => leadGenState?.quote,
leadGenServiceZip: (state) => leadGenState?.serviceZip,
leadGenEstimate: (state) => leadGenState?.estimate,
};
function getNonFalseValuesOfPropertyInArrayOfObjects(array, propertyName) {
@ -1934,13 +2021,11 @@ export const actions = {
context.state.order.vehicle.year != year ||
context.state.order.vehicle.make != make ||
context.state.order.vehicle.model != model ||
context.state.order.vehicle.style != style ||
context.state.order.isLeadGen
context.state.order.vehicle.style != style
) {
if (!context.state.order.isLeadGen) {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
}
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_YEAR, year);
context.commit(storeMutations.UPDATE_MAKE, make);
@ -2705,14 +2790,27 @@ export const actions = {
//restore user's experiments
context.commit(storeMutations.UPDATE_EXPERIMENTS, experiments);
//clear leadGen session storage
window.sessionStorage.removeItem("leadGenState");
},
resetSubmittedOrder(context) {
// clear from local storage
window.sessionStorage.removeItem("submittedOrder");
},
resetIsLeadGen(context) {
context.commit(storeMutations.UPDATE_IS_LEAD_GEN, false);
resetLeadGenState(context) {
if (context.getters.isLeadGen) {
context.commit(storeMutations.RESET_LEADGEN_VEHICLE_STATE);
context.commit(storeMutations.RESETL_EADGEN_DAMAGE_STATE);
context.commit(storeMutations.RESET_LEADGEN_ESTIMATE_STATE);
context.commit(storeMutations.RESET_LEADGEN_SERVICEZIP_STATE);
context.commit(storeMutations.RESET_LEADGEN_QUOTE_STATE);
context.commit(storeMutations.RESET_IS_LEADGEN);
}
},
createLeadGenState(context) {
createLeadGenDefaultState();
},
};
@ -3201,3 +3299,43 @@ async function resetScheduleIfUnavailable(context, order, pageNameToLog) {
}
}
}
function createLeadGenDefaultState() {
// create default leadGen state
const leadGenDefaultState = {
isLeadGen: null,
vehicle: {
year: null,
make: null,
model: null,
style: null,
},
vehicleDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
estimate: {
vinSelection: null,
},
serviceZip: {
emailAddress: null,
zipCode: null,
},
quote: {
isInsurance: null,
servicePackage: null,
},
};
// set to session storage
setLeadGenState(leadGenDefaultState);
}
function getLeadGenDefaultState() {
const leadGenState = window.sessionStorage.getItem("leadGenState");
if (leadGenState === null) {
createLeadGenDefaultState();
}
return JSON.parse(window.sessionStorage.getItem("leadGenState"));
}
async function setLeadGenState(leadGenState) {
window.sessionStorage.setItem("leadGenState", JSON.stringify(leadGenState));
}