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_DATE: "updateReferralDate",
|
||||
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
||||
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
|
||||
|
||||
// EVENT BUS MUTATIONS
|
||||
ADD_EVENT_TO_BUS: "addEventToBus",
|
||||
|
|
|
|||
|
|
@ -6,22 +6,23 @@ import router from "@/router";
|
|||
import baseMixin from "../mixins/base-mixin";
|
||||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
export function handleInfoFromHeritageFunnel() {
|
||||
export async function loadReferralFromHeritageFunnelIfPresent() {
|
||||
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);
|
||||
deleteHeritageCookie();
|
||||
}
|
||||
else if (orderInfo?.DidHeritageFunnelUpdateLast) {
|
||||
// Load referral here
|
||||
|
||||
// setHeritageCookieProperties({
|
||||
// ShouldResetState: false
|
||||
// })
|
||||
return;
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe("saveOrder", () => {
|
|||
}
|
||||
}
|
||||
|
||||
describe("handleInfoFromHeritageFunnel", () => {
|
||||
describe("loadReferralFromHeritageFunnelIfPresent", () => {
|
||||
// test("ShouldResetState == true => heritage cookie is deleted", () => {
|
||||
// // Arrange
|
||||
// // TODO CSR-98 Can we not mock this??
|
||||
|
|
@ -42,7 +42,7 @@ describe("saveOrder", () => {
|
|||
// console.log(document.cookie)
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||
|
||||
// // Assert
|
||||
// console.log(document.cookie)
|
||||
|
|
@ -54,7 +54,7 @@ describe("saveOrder", () => {
|
|||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = false);
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||
|
||||
// // Assert
|
||||
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||
|
|
@ -65,7 +65,7 @@ describe("saveOrder", () => {
|
|||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = true);
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
// helper.loadReferralFromHeritageFunnelIfPresent();
|
||||
|
||||
// // Assert
|
||||
// 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 { globalEvents, globalEventTypes } from "@/constants/events";
|
||||
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 eventBus from "@/helpers/event-bus/event-bus";
|
||||
|
|
@ -33,7 +33,7 @@ const routes = [
|
|||
// On entering the concept funnel
|
||||
if (from.redirectedFrom === undefined) {
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const getDefaultState = () => {
|
|||
referralNumber: null,
|
||||
referralDate: null,
|
||||
referralCorrelationId: null,
|
||||
parentAccountNumber: null,
|
||||
},
|
||||
applicationUser: {
|
||||
eventBus: [],
|
||||
|
|
@ -97,6 +98,10 @@ export const mutations = {
|
|||
updateReferralDate(state, referralDate) {
|
||||
state.order.referralDate = referralDate;
|
||||
},
|
||||
updateParentAcctNumber(state, parentAcctNumber) {
|
||||
state.order.parentAccountNumber = parentAcctNumber;
|
||||
},
|
||||
|
||||
|
||||
// EVENT BUS MUTATIONS
|
||||
addEventToBus(state, event) {
|
||||
|
|
@ -143,7 +148,25 @@ export const mutations = {
|
|||
|
||||
// Misc Mutations
|
||||
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