From 5a8c5365f51f8c8c1c6de154961315551c16d0e6 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 8 Dec 2022 11:55:58 -0500 Subject: [PATCH] CSR-747 Add load-session parameters --- src/constants/tint-mapper.js | 2 +- .../heritage-integration/order-helper.js | 14 ++++++++++++-- src/store/index.js | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/constants/tint-mapper.js b/src/constants/tint-mapper.js index 308b9a92d..fab6d508f 100644 --- a/src/constants/tint-mapper.js +++ b/src/constants/tint-mapper.js @@ -78,7 +78,7 @@ const tintMap = { // Returns undefined if no items are found. export function getTintImage(glassLocation, colorString) { // Windshield glass has special images, all other glass uses the same though. - if (glassLocation.toLowerCase() !== "windshield") { + if (glassLocation?.toLowerCase() !== "windshield") { glassLocation = "other"; } diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 9a24e9c24..6b5e63c49 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -30,7 +30,14 @@ export async function loadSessionIfPresent() { } // Loads session including referral if there is a cookie, and it doesn't indicate it needs a state reset. - return (await loadSession(funnelCookie.SavedSessionId)).data; + return ( + await loadSession( + funnelCookie.SavedSessionId, + funnelCookie.ReferralNumber, + funnelCookie.ReferralParentAccountNumber, + funnelCookie.ReferralCorrelationId + ) + ).data; } /* @@ -61,13 +68,16 @@ export async function saveSession() { Calls API to load session given the referral number, referralDate, and referralCorrelationId and returns the response. */ -async function loadSession(savedSessionId) { +async function loadSession(savedSessionId, referralNumber, accountNumber, referralCorrelationId) { // await the saveSessionPromise in the store to make sure we're loading up to date information await store.getters.applicationUser.saveSessionPromise; const response = await baseMixin.methods.dispatchStoreAction( storeActions.LOAD_SESSION, { savedSessionId: savedSessionId?.toString(), + referralNumber, + accountNumber, + referralCorrelationId, }, false ); diff --git a/src/store/index.js b/src/store/index.js index ab96eb9d1..1d528458f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -368,7 +368,7 @@ export const mutations = { sessionInformation?.order.payment.insuranceCoverage.isVerified; // TODO KO CSR-747 double check this state.order.payment.insuranceCoverage.coverageStatus = - sessionInformation?.insuranceInfo.coverageStatus; + sessionInformation?.insuranceInfo?.coverageStatus; state.order.customer.emailAddress = sessionInformation.order.customer.emailAddress; state.order.existingPromoCode = sessionInformation.order.existingPromoCode; @@ -1036,12 +1036,21 @@ export const actions = { }, }); }, - loadSession(context, { savedSessionId }) { + loadSession(context, { savedSessionId, referralNumber, referralCorrelationId, accountNumber }) { + const order = context.state.order; + return globalMethods .callHttpClient({ method: endpoints.LoadSession.method, - endpoint: - endpoints.LoadSession.url + "?savedSessionId=" + savedSessionId?.toString(), + endpoint: `${ + endpoints.LoadSession.url + }?savedSessionId=${savedSessionId?.toString()}&referralNumber=${ + referralNumber && referralNumber !== "" ? referralNumber : order.referralNumber + }&accountNumber=${accountNumber}&referralCorrelationId=${ + referralCorrelationId !== "" + ? referralCorrelationId + : order.referralCorrelationId + }`, }) .then((response) => { // Flatten location and name properties