diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index a34d8990..f201efba 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -146,6 +146,10 @@ const endpoints = Object.freeze({ url: '/order/api/v1/order/save-session/iss', method: 'POST' }, + LoadSession: { + url: '/order/api/v1/order/load-session', + method: 'POST' + }, DuplicateSearch: { // eslint-disable-next-line max-len url: (accountNumber, policyNumber, phoneNumber) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${phoneNumber}`, diff --git a/src/store/index.js b/src/store/index.js index 1568c5b7..4bb69ffa 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -140,7 +140,7 @@ const getDefaultState = () => ({ pageData: {}, savedSessionTimeout: getDateForSavedSessionTimeout(), saveSessionPromise: null, - savedSessionId: null, + savedSessionId: '00000000-0000-0000-0000-000000000000', crmCustomerId: null, lastPageVisited: null, triggeredSiteEntry: false, @@ -937,6 +937,75 @@ export const useMainStore = defineStore({ }); }, + loadSession() { + // TODO how to get savedSessionId for a duplicate referral? + const result = globalMethods.callHttpClient({ + method: endpoints.SaveSession.method, + endpoint: endpoints.SaveSession.url, + payload: { + savedSessionId: this.applicationUser.savedSessionId?.toString(), + referralNumber: this.order.referralNumber?.toString(), + referralDate: this.order.referralDate?.toString(), + parentAccountNumber: this.issConfig.parentAccountNumber, + referralCorrelationId: this.order.referralCorrelationId + } + }); + this.applicationUser.crmCustomerId = result.applicationUser.crmCustomerId; + this.applicationUser.experiments = result.applicationUser.experiments; + this.applicationUser.lastPageVisited = result.applicationUser.lastPage; + this.applicationUser.pageData = result.applicationUser.pageData; + this.applicationUser.savedSessionId = result.applicationUser.savedSessionId; // TODO this might just be what is passed + + this.order.vehicle.registration.licensePlate = result.order.vehicle.registration.licensePlateNumber; + this.order.vehicle.imageUrl = result.order.vehicle.imageUrl; + this.order.vehicle.imageColor = result.order.vehicle.imageVifColor; + this.order.vehicle.imageVifNumber = result.order.vehicle.imageNumber; + this.order.vehicle.year = result.order.vehicle.year; + this.order.vehicle.make = result.order.vehicle.make; + this.order.vehicle.model = result.order.vehicle.model; + this.order.vehicle.style = result.order.vehicle.style; + this.order.vehicle.carId = result.order.vehicle.carId; + this.order.vehicle.category = result.order.vehicle.category; + this.order.vehicle.vin = result.order.vehicle.vin; + + this.order.damage.isRepair = result.order.damage.isRepair; + this.order.damage.numberOfChips = result.order.damage.numberOfChips; + this.order.damage.glassToReplace = result.order.damage.glassToReplace; // TODO this might need transformed + this.order.damage.capabilityQuestionAnswers = result.order.damage.capabilityQuestionAnswers; + this.order.damage.moldingQuestionAnswers = result.order.damage.moldingQuestionAnswers; + this.order.damage.partQuestionAnswers = result.order.damage.partQuestionAnswers; + + this.order.policy.policyNumber = result.order.policy.policyNumber; + this.order.policy.policyZipCode = result.order.policy.policyZipCode; + this.order.policy.noCoverage = result.order.policy.noCoverage; + this.order.policy.policyLookupSuccessful = result.order.policy.policyLookupSuccessful; // TODO probably don't need to load this + this.order.policy.dateOfLoss = result.order.damage.dateOfLoss; + this.order.policy.damageCause = result.order.damage.damageCause; + this.order.policy.damageState = result.order.damage.damageState; + this.order.policy.damageCity = result.order.damage.damageCity; + this.order.policy.isDamageGlassOnly = result.order.damage.isDamageGlassOnly; + + + this.order.originalDeductible = result.order.policy.originalDeductible; + this.order.currentDeductible = result.order.policies.currentDeductible; + + + // customer: { + // address: { + // streetAddress: null, + // streetAddress2: null, + // city: null, + // state: null, + // zipCode: null + // }, + // firstName: null, + // lastName: null, + // emailAddress: null, + // phoneNumber: null + // }, + + }, + setSaveSessionPromise(promise) { this.applicationUser.saveSessionPromise = promise; },