create session storage
This commit is contained in:
hiteshkumar87 2024-07-18 20:15:09 +05:30
parent 2e12fb3c90
commit ac873bf893
24 changed files with 491 additions and 238 deletions

View file

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

View file

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

View file

@ -88,6 +88,28 @@ const storeMutations = {
// EXPERIMENT MUTATIONS // EXPERIMENT MUTATIONS
UPDATE_EXPERIMENTS: "updateExperiments", UPDATE_EXPERIMENTS: "updateExperiments",
UPDATE_TRIGGERED_SITE_ENTRY: "updateTriggeredSiteEntry", 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_PACKAGE_SELECTION: "updateLeadGenPackageSelection",
//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 }; export { storeMutations };

View file

@ -230,6 +230,15 @@ export function getHighestFullySatisfiedTier(glassToReplace, availableLineItems,
return highestSatisfiedPackage; 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) { function maxTier(tierA, tierB) {
if (tierA === packageNames.TIER_THREE || tierB === packageNames.TIER_THREE) { if (tierA === packageNames.TIER_THREE || tierB === packageNames.TIER_THREE) {
return 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 { storeActions } from "@/constants/store-actions";
import { routerParams } from "@/router/router-constants/router-params"; import { routerParams } from "@/router/router-constants/router-params";
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper"; import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store"; import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin"; import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -150,6 +150,10 @@ export default {
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
}); });
}, },
data() { data() {

View file

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

View file

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

View file

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

View file

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

View file

@ -58,6 +58,9 @@ jest.mock("@/mixins/base-mixin", () => ({
filterOutFees(items) { filterOutFees(items) {
return null; return null;
}, },
isFormValid(form) {
return true;
},
}, },
})); }));
@ -66,6 +69,9 @@ const mockMixin = {
filterOutFees: jest.fn().mockImplementation(() => { filterOutFees: jest.fn().mockImplementation(() => {
return null; return null;
}), }),
isFormValid: jest.fn().mockImplementation(() => {
return true;
}),
getSettingValue: jest.fn((settingName) => { getSettingValue: jest.fn((settingName) => {
if (settingName === experimentSettings.SERVICE_PACKAGE_DISCOUNT) { if (settingName === experimentSettings.SERVICE_PACKAGE_DISCOUNT) {
return true; return true;
@ -641,7 +647,7 @@ describe("quote.vue", () => {
}); });
}); });
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 // Set up the store with isLeadGen as true
store.getters = { store.getters = {
@ -666,6 +672,10 @@ describe("quote.vue", () => {
}, },
}, },
isLeadGen: true, isLeadGen: true,
leadGenQuote: {
isInsurance: true,
packageSelection: "glassonly",
},
payment: { payment: {
isInsurance: true, isInsurance: true,
inactivePromos: [], inactivePromos: [],
@ -693,61 +703,8 @@ describe("quote.vue", () => {
undefined, undefined,
nextFunction nextFunction
); );
await nextTick();
expect(nextFunction).toHaveBeenCalled(); expect(nextFunction).toHaveBeenCalled();
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();
}); });
}); });
@ -755,10 +712,10 @@ function setupMocks({ customMountOptions }) {
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
...customMountOptions, ...customMountOptions,
}); });
baseMixin.methods.hideFmgLoadingModal = jest.fn(); baseMixin.methods.hideFmgLoadingModal = jest.fn();
mountOptions.global.mocks["$store"] = store; mountOptions.global.mocks["$store"] = store;
mountOptions["attachTo"] = document.body; mountOptions["attachTo"] = document.body;
const wrapper = shallowMount(quote, mountOptions); const wrapper = shallowMount(quote, mountOptions);
wrapper.vm.setCmsContent = jest.fn(); wrapper.vm.setCmsContent = jest.fn();
return { wrapper }; return { wrapper };

View file

@ -30,6 +30,7 @@
:isInsuranceSelected="isInsuranceSelected" :isInsuranceSelected="isInsuranceSelected"
@vapsItemsSelected="vapsItemsSelectedAction" @vapsItemsSelected="vapsItemsSelectedAction"
@servicePackageDiscountSelected="servicePackageDiscountSelectedAction" @servicePackageDiscountSelected="servicePackageDiscountSelectedAction"
:packageSelection="packageSelection"
:activePromos="lineItems.promos" :activePromos="lineItems.promos"
v-on="{ 'buttonEvent.openModal': openModalAction }" v-on="{ 'buttonEvent.openModal': openModalAction }"
validationRules="option-required" validationRules="option-required"
@ -118,6 +119,7 @@ import promoModalQuestion from "@/fmg-components/promo-modal-question/promo-moda
import { experimentSettings } from "@/constants/experiments"; import { experimentSettings } from "@/constants/experiments";
import { partTypeStrings } from "@/constants/part-type-strings"; import { partTypeStrings } from "@/constants/part-type-strings";
import { containsLineItemWithPartType } from "@/helpers/service-package-helper"; import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
import { nextTick } from "vue";
defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
export default { export default {
@ -227,7 +229,7 @@ export default {
// End of promo logic // End of promo logic
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.addableVaps = addableVaps; vm.addableVaps = addableVaps;
vm.lineItems = lineItems; vm.lineItems = lineItems;
@ -253,14 +255,23 @@ export default {
); );
} }
if (store.getters.isLeadGen) { if (store.getters.isLeadGen) {
if (store.getters.order.payment.isInsurance == true) { if (store.getters.leadGenQuote.isInsurance == true) {
vm.forwardButtonAction(); vm.isInsuranceSelected = true;
vm.packageSelection = store.getters.leadGenQuote.packageSelection;
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 { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
} else { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
}); });
@ -271,6 +282,7 @@ export default {
availableLineItems: null, availableLineItems: null,
lineItems: [], lineItems: [],
addableVaps: [], addableVaps: [],
packageSelection: null,
}; };
}, },
computed: { computed: {

View file

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

View file

@ -154,6 +154,10 @@ function resetMockStoreData() {
jobMaxMinutes: null, jobMaxMinutes: null,
jobMinMinutes: null, jobMinMinutes: null,
}, },
leadGenServiceZip: {
zipCode: null,
emailAddress: null,
},
}; };
} }
@ -163,6 +167,7 @@ function applyMockStoreDataToGetters() {
damage: mockStoreData.damage, damage: mockStoreData.damage,
payment: mockStoreData.payment, payment: mockStoreData.payment,
policy: mockStoreData.policy, policy: mockStoreData.policy,
leadGenServiceZip: mockStoreData.leadGenServiceZip,
}; };
store.state.order = mockStoreData; store.state.order = mockStoreData;
} }
@ -403,9 +408,7 @@ describe("service-zip.vue", () => {
}); });
// Mock the isFormValid method // Mock the isFormValid method
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => { baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
return true;
});
// Call the method that contains the if-else logic // Call the method that contains the if-else logic
await serviceZip.beforeRouteEnter.call( await serviceZip.beforeRouteEnter.call(
@ -429,7 +432,7 @@ describe("service-zip.vue", () => {
}); });
// Mock the isFormValid method // Mock the isFormValid method
wrapper.vm.isFormValid = jest.fn().mockImplementation(() => { baseMixin.methods.isFormValid = jest.fn().mockImplementation(() => {
return false; return false;
}); });
@ -450,6 +453,7 @@ function setupMocks({ customMountOptions, customZipQuery, customZipDataResponse
route.query.zipcode = customZipQuery; route.query.zipcode = customZipQuery;
} }
baseMixin.methods.hideFmgLoadingModal = jest.fn(); baseMixin.methods.hideFmgLoadingModal = jest.fn();
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
...customMountOptions, ...customMountOptions,
route: route, route: route,

View file

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

View file

@ -67,6 +67,11 @@ jest.mock("@/store", () => ({
}, },
}, },
isLeadGen: false, isLeadGen: false,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}, },
})); }));
@ -148,6 +153,11 @@ describe("vehicle-damage.vue", () => {
getters: { getters: {
vehicle: {}, vehicle: {},
payment: { insuranceCoverage: { isVerified: false } }, payment: { insuranceCoverage: { isVerified: false } },
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}, },
}, },
}, },
@ -183,6 +193,7 @@ describe("vehicle-damage.vue", () => {
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
wrapper.vm.isFormValid = jest.fn();
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
@ -257,6 +268,11 @@ describe("vehicle-damage.vue", () => {
getters: { getters: {
vehicle: {}, vehicle: {},
payment: { insuranceCoverage: { isVerified: false } }, payment: { insuranceCoverage: { isVerified: false } },
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}, },
}, },
}, },
@ -278,7 +294,7 @@ describe("vehicle-damage.vue", () => {
undefined, undefined,
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
wrapper.vm.isFormValid = jest.fn();
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
@ -540,6 +556,11 @@ describe("vehicle-damage.vue", () => {
eventBusItem: jest.fn(), eventBusItem: jest.fn(),
damage: { glassToReplace: [{ glassLocation: damageLocation }] }, damage: { glassToReplace: [{ glassLocation: damageLocation }] },
isRepair: true, isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}; };
var glassSelections = wrapper.vm.getDamageLocationsFromStore(); var glassSelections = wrapper.vm.getDamageLocationsFromStore();
@ -617,6 +638,11 @@ describe("vehicle-damage.vue", () => {
isRepair: isRepair, isRepair: isRepair,
numberOfChips: 2, numberOfChips: 2,
}, },
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}; };
var windshieldSelections = wrapper.vm.getWindshieldOptionsFromStore(); var windshieldSelections = wrapper.vm.getWindshieldOptionsFromStore();
@ -653,6 +679,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
}, },
isRepair: true, isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}; };
var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore(); var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore();
@ -689,6 +720,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
}, },
isRepair: true, isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}; };
var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore(); var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore();
@ -723,6 +759,11 @@ describe("vehicle-damage.vue", () => {
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
}, },
isRepair: true, isRepair: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}; };
var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore(); var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore();
@ -744,6 +785,11 @@ describe("vehicle-damage.vue", () => {
vehicle: {}, vehicle: {},
payment: { insuranceCoverage: { isVerified: true } }, payment: { insuranceCoverage: { isVerified: true } },
requiresVerifiedRedirecting: true, requiresVerifiedRedirecting: true,
leadGenDamage: {
damageType: null,
isRepair: null,
numberOfChips: null,
},
}, },
}, },
}, },
@ -763,20 +809,24 @@ describe("vehicle-damage.vue", () => {
}); });
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 // Set up the store with isLeadGen as true
store.getters.isLeadGen = true; store.getters.isLeadGen = true;
store.getters.leadGenDamage = {
damageType: "windshieldReplace",
isRepair: false,
numberOfChips: null,
};
// Set up the component // Set up the component
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
wrapper.vm.forwardButtonAction = jest.fn(); wrapper.vm.forwardButtonAction = jest.fn();
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const nextFunction = jest.fn((c) => { const nextFunction = jest.fn((c) => {
c(wrapper.vm); c(wrapper.vm);
}); });
// Set selectedDamageLocations
wrapper.setData({ selectedDamageLocations: ["windshield"] });
// Call the method that contains the if-else logic // Call the method that contains the if-else logic
await vehicleDamage.beforeRouteEnter.call( await vehicleDamage.beforeRouteEnter.call(
wrapper.vm, wrapper.vm,
@ -784,32 +834,10 @@ describe("vehicle-damage.vue", () => {
undefined, undefined,
nextFunction nextFunction
); );
await nextTick();
expect(nextFunction).toHaveBeenCalled(); expect(nextFunction).toHaveBeenCalled();
expect(wrapper.vm.forwardButtonAction).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, 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 store from "@/store";
import baseMixin from "@/mixins/base-mixin"; import baseMixin from "@/mixins/base-mixin";
import { nextTick } from "vue";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED)); defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
@ -136,7 +137,7 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions); vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions);
vm.$refs.sideDoorOptions.initializeComponent( vm.$refs.sideDoorOptions.initializeComponent(
@ -150,14 +151,16 @@ export default {
resultMap.damageOptions.backGlassOptions.availableReplacementOptions resultMap.damageOptions.backGlassOptions.availableReplacementOptions
); );
if (store.getters.isLeadGen) { if (store.getters.isLeadGen) {
if (vm.selectedDamageLocations?.length > 0) { await nextTick();
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
if (isValid) {
vm.forwardButtonAction(); vm.forwardButtonAction();
} else { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
} else { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
}); });
@ -184,7 +187,6 @@ export default {
} }
return false; return false;
}, },
attachCustomEvents() { attachCustomEvents() {
if (this.$store.getters.vehicle.imageVifNumber) { if (this.$store.getters.vehicle.imageVifNumber) {
this.pushEventToGA( this.pushEventToGA(
@ -208,7 +210,9 @@ export default {
store.getters.damage.glassToReplace?.some((glass) => { store.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.WINDSHIELD; 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); glassSelections.push(damageLocationsSelected.WINDSHIELD);
} }
@ -241,11 +245,13 @@ export default {
selectedWindshieldReplaceOptions: [], selectedWindshieldReplaceOptions: [],
}; };
if (store.getters.damage.isRepair === undefined) return windshieldOptions; if (store.getters.leadGenDamage.isRepair || 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.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
windShieldOptions.selectedWindshieldChipCount = store.getters.damage.numberOfChips; windShieldOptions.selectedWindshieldChipCount =
store.getters.leadGenDamage.numberOfChips || store.getters.damage.numberOfChips;
} else { } else {
if ( if (
store.getters.damage.glassToReplace?.some((glass) => { store.getters.damage.glassToReplace?.some((glass) => {
@ -253,7 +259,8 @@ export default {
glass.glassLocation === damageLocationsSelected.WINDSHIELD && glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.glassName === damageLocationsSelected.SINGLE glass.glassName === damageLocationsSelected.SINGLE
); );
}) }) ||
store.getters.leadGenDamage.damageType?.toUpperCase() === "WINDSHIELDREPLACE"
) { ) {
windShieldOptions.selectedWindshieldDamageType = windShieldOptions.selectedWindshieldDamageType =
damageLocationsSelected.REPLACE; damageLocationsSelected.REPLACE;
@ -350,6 +357,8 @@ export default {
}, },
async forwardButtonAction() { async forwardButtonAction() {
const isValid = await this.isFormValid();
console.log(isValid);
await this.dispatchStoreAction( await this.dispatchStoreAction(
this.storeActions.SAVE_VEHICLE_DAMAGE, this.storeActions.SAVE_VEHICLE_DAMAGE,
{ {

View file

@ -29,6 +29,12 @@ jest.mock("@/store", () => ({
experiments: [{ universeName: "ConceptFunnel" }], experiments: [{ universeName: "ConceptFunnel" }],
}, },
isLeadGen: false, isLeadGen: false,
leadGenVehicle: {
year: null,
make: null,
model: null,
style: null,
},
vehicle: { vehicle: {
carId: "C00000000", carId: "C00000000",
image: "test.jpg", image: "test.jpg",
@ -87,50 +93,21 @@ describe("vehicle.vue", () => {
}); });
describe("vehicle.vue", () => { describe("vehicle.vue", () => {
test("should call forwardButtonAction if isLeadGen is true and displayNoServiceAlert is false", 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.isLeadGen = true;
// Create a shallow mount of MyComponent
// Set up the component
const { wrapper } = setupMocks(); const { wrapper } = setupMocks();
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Set displayNoServiceAlert to false // Set displayNoServiceAlert to false
wrapper.setData({ displayNoServiceAlert: false }); wrapper.setData({ displayNoServiceAlert: false });
// Mock the getVehicleDetails method // Mock the getVehicleDetails method
wrapper.vm.getVehicleDetails = jest.fn(); 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(); wrapper.vm.forwardButtonAction = jest.fn();
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const nextFunction = jest.fn((c) => { const nextFunction = jest.fn((c) => {
c(wrapper.vm); 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 // Call the method that contains the if-else logic
await vehicle.beforeRouteEnter.call( await vehicle.beforeRouteEnter.call(
wrapper.vm, wrapper.vm,
@ -138,7 +115,10 @@ describe("vehicle.vue", () => {
undefined, undefined,
nextFunction 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; var styleQuestionInitialDataPromise = null;
if ( if (
store.getters.order.vehicle.make && (store.getters.leadGenVehicle.make || store.getters.order.vehicle.make) &&
store.getters.order.vehicle.model && (store.getters.leadGenVehicle.model || store.getters.order.vehicle.model) &&
store.getters.order.vehicle.style (store.getters.leadGenVehicle.style || store.getters.order.vehicle.style)
) { ) {
makeQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging( makeQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_MAKES, storeActions.GET_VEHICLE_MAKES,
{ {
year: store.getters.order.vehicle.year, year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
}, },
"vehicle" "vehicle"
); );
@ -158,8 +158,8 @@ export default {
modelQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging( modelQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_MODELS, storeActions.GET_VEHICLE_MODELS,
{ {
year: store.getters.order.vehicle.year, year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
make: store.getters.order.vehicle.make, make: store.getters.leadGenVehicle.make || store.getters.order.vehicle.make,
}, },
"vehicle" "vehicle"
); );
@ -167,9 +167,9 @@ export default {
styleQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging( styleQuestionInitialDataPromise = baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.GET_VEHICLE_STYLES, storeActions.GET_VEHICLE_STYLES,
{ {
year: store.getters.order.vehicle.year, year: store.getters.leadGenVehicle.year || store.getters.order.vehicle.year,
make: store.getters.order.vehicle.make, make: store.getters.leadGenVehicle.make || store.getters.order.vehicle.make,
model: store.getters.order.vehicle.model, model: store.getters.leadGenVehicle.model || store.getters.order.vehicle.model,
}, },
"vehicle" "vehicle"
); );
@ -235,13 +235,19 @@ export default {
if (store.getters.isLeadGen) { if (store.getters.isLeadGen) {
await vm.getVehicleDetails(); await vm.getVehicleDetails();
if (!vm.displayNoServiceAlert) { 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 { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
} else { } else {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal(); baseMixin.methods.hideFmgLoadingModal();
} }
}); });
@ -429,16 +435,16 @@ export default {
this.styleOptions = styleOptions; this.styleOptions = styleOptions;
}, },
selectedYearfromStore() { selectedYearfromStore() {
return store.getters.vehicle.year?.toString(); return store.getters.leadGenVehicle.year ?? store.getters.vehicle.year?.toString();
}, },
selectedMakefromStore() { selectedMakefromStore() {
return store.getters.vehicle.make; return store.getters.leadGenVehicle.make ?? store.getters.vehicle.make;
}, },
selectedModelfromStore() { selectedModelfromStore() {
return store.getters.vehicle.model; return store.getters.leadGenVehicle.model ?? store.getters.vehicle.model;
}, },
selectedStylefromStore() { selectedStylefromStore() {
return store.getters.vehicle.style; return store.getters.leadGenVehicle.style ?? store.getters.vehicle.style;
}, },
async getMakeOptions(year) { async getMakeOptions(year) {
return await baseMixin.methods.dispatchStoreActionWithLogging( 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 { 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 { routerParams } from "@/router/router-constants/router-params";
import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store"; import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin"; import vinPagesMixin from "@/mixins/vin-pages-mixin";
@ -192,6 +192,10 @@ export default {
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
if (store.getters.isLeadGen) {
baseMixin.methods.dispatchStoreAction(storeActions.RESET_LEADGEN_STATE);
baseMixin.methods.hideFmgLoadingModal();
}
}); });
}, },
data() { data() {

View file

@ -196,6 +196,10 @@ export default {
hideFmgLoadingModal() { hideFmgLoadingModal() {
showFmgLoadingModal(false); showFmgLoadingModal(false);
}, },
async isFormValid(form) {
const formValidateResponse = await form?.validate();
return formValidateResponse?.valid;
},
}, },
computed: { computed: {
storeActions() { storeActions() {

View file

@ -3,6 +3,7 @@ import store from "@/store";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin"; import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { saveSession } from "@/helpers/heritage-integration/order-helper.js"; import { saveSession } from "@/helpers/heritage-integration/order-helper.js";
import { experimentSettings } from "@/constants/experiments"; import { experimentSettings } from "@/constants/experiments";
import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js";
export default { export default {
computed: { computed: {
@ -32,5 +33,14 @@ export default {
vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this); 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 { applicationConfig } from "../constants/application-config";
import { shouldStripPromoQueryString } from "@/helpers/promotions-helper"; import { shouldStripPromoQueryString } from "@/helpers/promotions-helper";
import bailout from "@/layouts/bailout/bailout"; import bailout from "@/layouts/bailout/bailout";
import { nextTick } from "vue";
const routes = [ const routes = [
{ {
@ -84,14 +85,25 @@ const routes = [
); );
const parentAccount = getQuerystringParameter(queryStrings.PARENT_ACCOUNT); const parentAccount = getQuerystringParameter(queryStrings.PARENT_ACCOUNT);
const correlationId = getQuerystringParameter(queryStrings.CORRELATION_ID); const correlationId = getQuerystringParameter(queryStrings.CORRELATION_ID);
const vehicleYear = getQuerystringParameter(queryStrings.VEHICLE_YEAR); const leadGenYear = getQuerystringParameter(queryStrings.VEHICLE_YEAR);
const vehicleMake = getQuerystringParameter(queryStrings.VEHICLE_MAKE); const leadGenMake = getQuerystringParameter(queryStrings.VEHICLE_MAKE);
const vehicleModel = getQuerystringParameter(queryStrings.VEHICLE_MODEL); const leadGenModel = getQuerystringParameter(queryStrings.VEHICLE_MODEL);
const vehicleStyle = getQuerystringParameter(queryStrings.VEHICLE_STYLE); const leadGenStyle = getQuerystringParameter(queryStrings.VEHICLE_STYLE);
const vehicleDamage = getQuerystringParameter(queryStrings.VEHICLE_DAMAGE); const leadGenDamage = getQuerystringParameter(queryStrings.VEHICLE_DAMAGE);
const serviceZip = getQuerystringParameter(queryStrings.SERVICE_ZIP); const leadGenZipCode = getQuerystringParameter(queryStrings.SERVICE_ZIP);
const email = getQuerystringParameter(queryStrings.EMAIL); const leadGenEmail = getQuerystringParameter(queryStrings.EMAIL);
const isInsurance = getQuerystringParameter(queryStrings.IS_INSURANCE); const leadGenIsInsurance = getQuerystringParameter(
queryStrings.IS_INSURANCE
);
const leadGenVinSelection = getQuerystringParameter(
queryStrings.VIN_SELECTION
);
const leadGenPackageSelection = getQuerystringParameter(
queryStrings.PACKAGE_SELECTION
);
const leadGenNumberOfChips = getQuerystringParameter(
queryStrings.NUMBER_OF_CHIPS
);
if (referralNumber) { if (referralNumber) {
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber); store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
store.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccount); store.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccount);
@ -102,47 +114,60 @@ const routes = [
updateOrCreateFunnelCookie(); updateOrCreateFunnelCookie();
} }
if ( if (
vehicleYear && leadGenYear &&
vehicleMake && leadGenMake &&
vehicleModel && leadGenModel &&
vehicleStyle && leadGenStyle &&
vehicleDamage && leadGenDamage &&
serviceZip && leadGenZipCode &&
email && leadGenEmail &&
isInsurance leadGenIsInsurance &&
leadGenVinSelection &&
leadGenPackageSelection &&
leadGenNumberOfChips
) { ) {
if (!store.getters.applicationUser.triggeredSiteEntry) { 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); store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
if (vehicleDamage == "windshieldReplace") { store.commit(storeMutations.UPDATE_LEAD_GEN_YEAR, leadGenYear);
store.commit(storeMutations.UPDATE_IS_REPAIR, false); store.commit(storeMutations.UPDATE_LEAD_GEN_MAKE, leadGenMake);
store.commit(storeMutations.UPDATE_NUMBER_OF_CHIPS, null); store.commit(storeMutations.UPDATE_LEAD_GEN_MODEL, leadGenModel);
const glassToReplace = [ store.commit(storeMutations.UPDATE_LEAD_GEN_STYLE, leadGenStyle);
{ glassLocation: "Windshield", glassName: "Single" }, store.commit(
]; storeMutations.UPDATE_LEAD_GEN_DAMAGE_TYPE,
leadGenDamage
);
if (leadGenDamage?.toUpperCase() == "WINDSHIELDREPLACE") {
store.commit(storeMutations.UPDATE_LEAD_GEN_IS_REPAIR, false);
store.commit( store.commit(
storeMutations.UPDATE_GLASS_TO_REPLACE, storeMutations.UPDATE_LEAD_GEN_NUMBER_OF_CHIPS,
glassToReplace 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 = { store.commit(
state: null, storeMutations.UPDATE_LEAD_GEN_ZIP_CODE,
zipCode: serviceZip, leadGenZipCode
zipCodeCtu: null, );
}; store.commit(
store.commit(storeMutations.UPDATE_SERVICE_ZIP, serviceZipInfo); storeMutations.UPDATE_LEAD_GEN_EMAIL_ADDRESS,
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email); leadGenEmail
if (isInsurance == "true") { );
store.commit(storeMutations.UPDATE_IS_INSURANCE, true); if (leadGenIsInsurance == "true") {
} else { store.commit(storeMutations.UPDATE_LEAD_GEN_IS_INSURANCE, true);
store.commit(storeMutations.UPDATE_IS_INSURANCE, null); store.commit(
storeMutations.UPDATE_LEAD_GEN_PACKAGE_SELECTION,
leadGenPackageSelection
);
} }
store.commit(
storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION,
leadGenVinSelection
);
} }
} }

View file

@ -160,7 +160,6 @@ const getDefaultState = () => {
customerPortalLoginToken: null, customerPortalLoginToken: null,
lockToken: null, lockToken: null,
settledTenderAmount: 0, settledTenderAmount: 0,
isLeadGen: false,
}, },
applicationUser: { applicationUser: {
eventBus: [], eventBus: [],
@ -177,7 +176,7 @@ const getDefaultState = () => {
}; };
export const state = getDefaultState(); export const state = getDefaultState();
export const leadGenState = getLeadGenDefaultState();
// Export Mutations // Export Mutations
export const mutations = { export const mutations = {
// VEHICLE MUTATIONS // VEHICLE MUTATIONS
@ -295,9 +294,6 @@ export const mutations = {
updateSettledTenderAmount(state, settledTenderAmount) { updateSettledTenderAmount(state, settledTenderAmount) {
state.order.settledTenderAmount = settledTenderAmount; state.order.settledTenderAmount = settledTenderAmount;
}, },
updateIsLeadGen(state, isLeadGen) {
state.order.isLeadGen = isLeadGen;
},
updateCCToken(state, ccToken) { updateCCToken(state, ccToken) {
state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId; state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId;
state.order.payment.ccToken.expMonth = ccToken.expMonth; state.order.payment.ccToken.expMonth = ccToken.expMonth;
@ -418,6 +414,91 @@ export const mutations = {
state.applicationUser.eventBus.splice(itemIndex, 1); 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);
},
updateLeadGenPackageSelection(state, packageSelection) {
leadGenState.quote.packageSelection = packageSelection;
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;
setLeadGenState(leadGenState);
},
resetIsLeadGen(state) {
leadGenState.isLeadGen = null;
setLeadGenState(leadGenState);
},
// RESET DEPENDENCY MUTATIONS // RESET DEPENDENCY MUTATIONS
resetVehicleState(state) { resetVehicleState(state) {
@ -678,7 +759,6 @@ export const getters = {
isOvernightDropOffAppointment: (state) => { isOvernightDropOffAppointment: (state) => {
return state.order.schedule.routeCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF); return state.order.schedule.routeCode?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF);
}, },
isLeadGen: (state) => state.order.isLeadGen,
isRecalibrationOnOrder: (state) => { isRecalibrationOnOrder: (state) => {
return getHasRecalibrationPart(state); return getHasRecalibrationPart(state);
}, },
@ -809,6 +889,12 @@ export const getters = {
requiresVerifiedRedirecting: (state) => { requiresVerifiedRedirecting: (state) => {
return state.order?.referralNumber?.length === 6; 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) { function getNonFalseValuesOfPropertyInArrayOfObjects(array, propertyName) {
@ -1932,13 +2018,11 @@ export const actions = {
context.state.order.vehicle.year != year || context.state.order.vehicle.year != year ||
context.state.order.vehicle.make != make || context.state.order.vehicle.make != make ||
context.state.order.vehicle.model != model || context.state.order.vehicle.model != model ||
context.state.order.vehicle.style != style || context.state.order.vehicle.style != style
context.state.order.isLeadGen
) { ) {
if (!context.state.order.isLeadGen) { 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);
}
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
context.commit(storeMutations.UPDATE_YEAR, year); context.commit(storeMutations.UPDATE_YEAR, year);
context.commit(storeMutations.UPDATE_MAKE, make); context.commit(storeMutations.UPDATE_MAKE, make);
@ -2703,14 +2787,27 @@ export const actions = {
//restore user's experiments //restore user's experiments
context.commit(storeMutations.UPDATE_EXPERIMENTS, experiments); context.commit(storeMutations.UPDATE_EXPERIMENTS, experiments);
//clear leadGen session storage
window.sessionStorage.removeItem("leadGenState");
}, },
resetSubmittedOrder(context) { resetSubmittedOrder(context) {
// clear from local storage // clear from local storage
window.sessionStorage.removeItem("submittedOrder"); window.sessionStorage.removeItem("submittedOrder");
}, },
resetIsLeadGen(context) { resetLeadGenState(context) {
context.commit(storeMutations.UPDATE_IS_LEAD_GEN, false); 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();
}, },
}; };
@ -3199,3 +3296,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,
packageSelection: 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));
}