Load init
This commit is contained in:
parent
1ac05c353b
commit
a279c9d011
5 changed files with 42 additions and 17 deletions
|
|
@ -19,6 +19,7 @@ const storeMutations = {
|
||||||
UPDATE_REFERRAL_NUMBER: "updateReferralNumber",
|
UPDATE_REFERRAL_NUMBER: "updateReferralNumber",
|
||||||
UPDATE_REFERRAL_DATE: "updateReferralDate",
|
UPDATE_REFERRAL_DATE: "updateReferralDate",
|
||||||
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
||||||
|
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
|
||||||
|
|
||||||
// EVENT BUS MUTATIONS
|
// EVENT BUS MUTATIONS
|
||||||
ADD_EVENT_TO_BUS: "addEventToBus",
|
ADD_EVENT_TO_BUS: "addEventToBus",
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,23 @@ import router from "@/router";
|
||||||
import baseMixin from "../mixins/base-mixin";
|
import baseMixin from "../mixins/base-mixin";
|
||||||
|
|
||||||
// Read info from heritage funnel and reset state or load referral
|
// Read info from heritage funnel and reset state or load referral
|
||||||
export function handleInfoFromHeritageFunnel() {
|
export async function loadReferralFromHeritageFunnelIfPresent() {
|
||||||
const orderInfo = getHeritageCookieValue();
|
const orderInfo = getHeritageCookieValue();
|
||||||
|
|
||||||
if (orderInfo?.ShouldResetState) {
|
// Do nothing if there is no cookie.
|
||||||
|
if(orderInfo === null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset state if cookie says to.
|
||||||
|
if (orderInfo.ShouldResetState) {
|
||||||
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
|
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE);
|
||||||
deleteHeritageCookie();
|
deleteHeritageCookie();
|
||||||
}
|
return;
|
||||||
else if (orderInfo?.DidHeritageFunnelUpdateLast) {
|
|
||||||
// Load referral here
|
|
||||||
|
|
||||||
// setHeritageCookieProperties({
|
|
||||||
// ShouldResetState: false
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("D")
|
// Load referral if there is a cookie, and it doesn't indicate it needs a state reset.
|
||||||
|
await loadOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function navigateToHeritageFunnel() {
|
export async function navigateToHeritageFunnel() {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ describe("saveOrder", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("handleInfoFromHeritageFunnel", () => {
|
describe("loadReferralFromHeritageFunnelIfPresent", () => {
|
||||||
// test("ShouldResetState == true => heritage cookie is deleted", () => {
|
// test("ShouldResetState == true => heritage cookie is deleted", () => {
|
||||||
// // Arrange
|
// // Arrange
|
||||||
// // TODO CSR-98 Can we not mock this??
|
// // TODO CSR-98 Can we not mock this??
|
||||||
|
|
@ -42,7 +42,7 @@ describe("saveOrder", () => {
|
||||||
// console.log(document.cookie)
|
// console.log(document.cookie)
|
||||||
|
|
||||||
// // Act
|
// // Act
|
||||||
// helper.handleInfoFromHeritageFunnel();
|
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||||
|
|
||||||
// // Assert
|
// // Assert
|
||||||
// console.log(document.cookie)
|
// console.log(document.cookie)
|
||||||
|
|
@ -54,7 +54,7 @@ describe("saveOrder", () => {
|
||||||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = false);
|
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = false);
|
||||||
|
|
||||||
// // Act
|
// // Act
|
||||||
// helper.handleInfoFromHeritageFunnel();
|
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||||
|
|
||||||
// // Assert
|
// // Assert
|
||||||
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||||
|
|
@ -65,7 +65,7 @@ describe("saveOrder", () => {
|
||||||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = true);
|
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = true);
|
||||||
|
|
||||||
// // Act
|
// // Act
|
||||||
// helper.handleInfoFromHeritageFunnel();
|
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||||
|
|
||||||
// // Assert
|
// // Assert
|
||||||
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"
|
||||||
import { routingTable } from "@/router/router-constants/routing-table.js";
|
import { routingTable } from "@/router/router-constants/routing-table.js";
|
||||||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||||
import { routerParameterKeys } from '@/router/router-constants/router-parameter-keys'
|
import { routerParameterKeys } from '@/router/router-constants/router-parameter-keys'
|
||||||
import { handleInfoFromHeritageFunnel, saveOrder, getHeritageCookieValue } from "@/helpers/heritage-integration-helper";
|
import { loadReferralFromHeritageFunnelIfPresent, saveOrder, getHeritageCookieValue } from "@/helpers/heritage-integration-helper";
|
||||||
|
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
import eventBus from "@/helpers/event-bus/event-bus";
|
import eventBus from "@/helpers/event-bus/event-bus";
|
||||||
|
|
@ -33,7 +33,7 @@ const routes = [
|
||||||
// On entering the concept funnel
|
// On entering the concept funnel
|
||||||
if (from.redirectedFrom === undefined) {
|
if (from.redirectedFrom === undefined) {
|
||||||
// Read cookie information, decide what to do next
|
// Read cookie information, decide what to do next
|
||||||
handleInfoFromHeritageFunnel();
|
loadReferralFromHeritageFunnelIfPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have no query string, or we don't have the FmgPage query string.
|
// If we have no query string, or we don't have the FmgPage query string.
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ const getDefaultState = () => {
|
||||||
referralNumber: null,
|
referralNumber: null,
|
||||||
referralDate: null,
|
referralDate: null,
|
||||||
referralCorrelationId: null,
|
referralCorrelationId: null,
|
||||||
|
parentAccountNumber: null,
|
||||||
},
|
},
|
||||||
applicationUser: {
|
applicationUser: {
|
||||||
eventBus: [],
|
eventBus: [],
|
||||||
|
|
@ -97,6 +98,10 @@ export const mutations = {
|
||||||
updateReferralDate(state, referralDate) {
|
updateReferralDate(state, referralDate) {
|
||||||
state.order.referralDate = referralDate;
|
state.order.referralDate = referralDate;
|
||||||
},
|
},
|
||||||
|
updateParentAcctNumber(state, parentAcctNumber) {
|
||||||
|
state.order.parentAccountNumber = parentAcctNumber;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// EVENT BUS MUTATIONS
|
// EVENT BUS MUTATIONS
|
||||||
addEventToBus(state, event) {
|
addEventToBus(state, event) {
|
||||||
|
|
@ -143,7 +148,25 @@ export const mutations = {
|
||||||
|
|
||||||
// Misc Mutations
|
// Misc Mutations
|
||||||
setLoadOrderInformation(state, orderInformation) {
|
setLoadOrderInformation(state, orderInformation) {
|
||||||
|
state.order.referralNumber = orderInformation.ReferralNumber;
|
||||||
|
state.order.referralDate = orderInformation.ReferralDate;
|
||||||
|
state.order.referralCorrelationId = orderInformation.CorrelationId;
|
||||||
|
state.order.vehicle = {
|
||||||
|
year: orderInformation.Year,
|
||||||
|
make: orderInformation.Make,
|
||||||
|
model: orderInformation.Model,
|
||||||
|
style: orderInformation.Style,
|
||||||
|
carId: orderInformation.CarId,
|
||||||
|
category: orderInformation.Category,
|
||||||
|
imageUrl: orderInformation.ImageUrl,
|
||||||
|
imageVifNumber: orderInformation.ImageVifNumber,
|
||||||
|
imageColor: orderInformation.ImageColor
|
||||||
|
};
|
||||||
|
state.order.damage.glassToReplace = orderInformation.GlassToReplace;
|
||||||
|
state.order.damage.isRepair = orderInformation.IsRepair;
|
||||||
|
state.order.damage.numberOfChips = orderInformation.NumberOfChips;
|
||||||
|
state.order.lineItems.glassParts = orderInformation.Parts;
|
||||||
|
state.order.parentAccountNumber = orderInformation.ParentAccountNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue