diff --git a/src/store/index.js b/src/store/index.js index 0e662b91..a490ac86 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2,16 +2,16 @@ /* eslint-disable no-use-before-define */ /* eslint-disable max-len */ import { defineStore } from 'pinia'; -import { endpoints } from '@/constants/endpoints'; +import { endpoints } from '@/constants/endpoints.js'; // eslint-disable-next-line import/no-cycle -import { getDateForSavedSessionTimeout } from '@/helpers/session-helper'; +import { getDateForSavedSessionTimeout } from '@/helpers/session-helper.js'; // eslint-disable-next-line import/no-cycle -import globalMethods from '@/global-methods'; -import { experimentTriggers } from '@/constants/experiments'; -import { applicationConfig } from '@/constants/application-config'; -import { issPageValues } from '@/router/router-constants/issPage-values'; -import { damageLocationsSelected } from '@/constants/damage-locations-selected'; -import { coverageStatuses } from '@/constants/coverage-statuses'; +import globalMethods from '@/global-methods.js'; +import { experimentTriggers } from '@/constants/experiments.js'; +import { applicationConfig } from '@/constants/application-config.js'; +import { issPageValues } from '@/router/router-constants/issPage-values.js'; +import { damageLocationsSelected } from '@/constants/damage-locations-selected.js'; +import { coverageStatuses } from '@/constants/coverage-statuses.js'; const storeId = 'main'; @@ -121,8 +121,7 @@ const getDefaultState = () => jobMaxMinutes: null }, referralNumber: null, - referralDate: null, - eon: null // TODO add + referralDate: null }, applicationUser: { experiments: [], @@ -709,7 +708,7 @@ export const useMainStore = defineStore({ saveSession() { // TODO use pieces of actual store - const { vehicle, damage, order, applicationUser, lineItems } = this.order; + const { vehicle, damage, policy, order, applicationUser, lineItems } = this.order; // TODO what does this method do const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace); @@ -717,8 +716,8 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.SaveSession.method, endpoint: endpoints.SaveSession.url, - // TODO update with payload for our store payload: { + // done applicationUser: { crmCustomerId: applicationUser.crmCustomerId, experiments: applicationUser.experiments, @@ -754,46 +753,48 @@ export const useMainStore = defineStore({ moldingQuestionAnswers: order.damage.moldingQuestionAnswers, capabilityQuestionAnswers: order.damage.capabilityQuestionAnswers }, + policy: { + policyNumber: policy.policyNumber, + policyZipCode: policy.policyZipCode, + dateOfLoss: policy.dateOfLoss, + damageCause: policy.damageCause, + damageState: policy.damageState, + damageCity: policy.damageCity, + isDamageGlassOnly: policy.isDamageGlassOnly, + noCoverage: policy.noCoverage + // deductible: { + // repair: policy.deductible.repair, + // replace: policy.deductible.replace + // } + }, + // NOTE using only customer info for now; ignoring contact details customer: { - emailAddress: order.contactInfo.emailAddress ?? order.customer.emailAddress, - firstName: order.contactInfo.firstName ?? order.customer.firstName, - lastName: order.contactInfo.lastName ?? order.customer.lastName, - phoneNumber: order.contactInfo.phoneNumber ?? order.customer.phoneNumber, // TODO contact info or customer? + emailAddress: order.customer.emailAddress, + firstName: order.customer.firstName, + lastName: order.customer.lastName, + phoneNumber: order.customer.phoneNumber, optInSms: order.contactInfo.requestTextUpdates ?? false }, lineItems: { glassParts: lineItems.glassParts, + otherData: lineItems.otherData, supportingItems: lineItems.supportingItems, - vaps: lineItems.vaps, - serverData: lineItems.serverData, + vaps: lineItems.vaps }, payment: { InsuranceCoverage: { isVerified: order.payment.insuranceCoverage.isVerified ?? false, + coverageStatus: order.payment.insuranceCoverage.coverageStatus }, - isInsurance: order.payment.isInsurance ?? false, - parentAccountNumber: order.payment.parentAccountNumber, + isInsurance: order.payment.isInsurance ?? true, + parentAccountNumber: order.payment.parentAccountNumber }, serviceLocation: { streetAddress: order.serviceLocation.address, - streetAddress2: order.serviceLocation.address2, city: order.serviceLocation.city, state: order.serviceLocation.state, zipCode: order.serviceLocation.zipCode, - zipCodeCtu: order.serviceLocation.zipCodeCtu, - appointmentType: order.serviceLocation.appointmentType, - isVehicleProtected: order.serviceLocation.isVehicleProtected, - provider: { - providerNumber: order.serviceLocation.provider?.providerNumber, - address: { - streetAddress: - order.serviceLocation.provider?.address?.streetAddress, - city: order.serviceLocation.provider?.address?.city, - state: order.serviceLocation.provider?.address?.state, - zipCode: order.serviceLocation.provider?.address?.zipCode, - zipCodeCtu: order.serviceLocation.provider?.address?.zipCodeCtu, - }, - }, + zipCodeCtu: order.serviceLocation.zipCodeCtu }, schedule: { date: order.schedule?.date, @@ -802,14 +803,14 @@ export const useMainStore = defineStore({ routeCode: order.schedule?.routeCode, jobMaxMinutes: order.schedule?.jobMaxMinutes, }, - existingPromoCode: null, - referralCorrelationId: order.referralCorrelationId, referralDate: order.referralDate, - referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place - referralSequenceNumber: order.referralNumber?.toString(), // TODO Pass the referralSequence number once insurance flow creates it - eon: order.eon + referralNumber: order.referralNumber?.toString(), + // TODO set + originalDeductible: 0, + currentDeductible: 0 } }, + // TODO maybe modify additionalSuccessEventDataHandler: (response) => `Email provided: ${order.customer.emailAddress ? 'true' : 'false'}` });