diff --git a/src/store/index.js b/src/store/index.js index f71aa9cd..ed1be634 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -17,7 +17,6 @@ const storeId = 'main'; const getDefaultState = () => ({ order: { - // Same as FMG vehicle: { year: null, make: null, @@ -39,7 +38,6 @@ const getDefaultState = () => ({ lastName: null } }, - // Same as FMG damage: { isRepair: null, numberOfChips: null, @@ -48,7 +46,6 @@ const getDefaultState = () => ({ moldingQuestionAnswers: null, capabilityQuestionAnswers: null }, - // DNE in FMG policy: { policyNumber: null, policyZipCode: null, @@ -64,8 +61,6 @@ const getDefaultState = () => ({ replace: null // numerical value; how much customer owes on deductible in replace case, } }, - // FMG only has email - // CSR-1358 and CSR-1359 customer: { address: { streetAddress: null, @@ -79,7 +74,6 @@ const getDefaultState = () => ({ emailAddress: null, phoneNumber: null }, - // Many more details in FMG serviceLocation: { address: null, city: null, @@ -696,17 +690,14 @@ export const useMainStore = defineStore({ }, saveSession() { - // TODO use pieces of actual store - const { vehicle, damage, policy, order, applicationUser, lineItems } = this.order; - - // TODO what does this method do + const { vehicle, damage, policy, customer, contactInfo, payment, applicationUser, + lineItems, serviceLocation, schedule } = this.order; const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace); return globalMethods.callHttpClient({ method: endpoints.SaveSession.method, endpoint: endpoints.SaveSession.url, payload: { - // done applicationUser: { crmCustomerId: applicationUser.crmCustomerId, experiments: applicationUser.experiments, @@ -728,9 +719,9 @@ export const useMainStore = defineStore({ numberOfChips: damage.numberOfChips, glassToReplace: newGlassToReplace, isRepair: damage.isRepair, - partQuestionAnswers: order.damage.partQuestionAnswers, - moldingQuestionAnswers: order.damage.moldingQuestionAnswers, - capabilityQuestionAnswers: order.damage.capabilityQuestionAnswers, + partQuestionAnswers: damage.partQuestionAnswers, + moldingQuestionAnswers: damage.moldingQuestionAnswers, + capabilityQuestionAnswers: damage.capabilityQuestionAnswers, dateOfLoss: policy.dateOfLoss, damageCause: policy.damageCause, damageState: policy.damageState, @@ -739,31 +730,31 @@ export const useMainStore = defineStore({ }, policy: { policyHolder: { - policyFirstName: order.customer.firstName, - policyLastName: order.customer.lastName, - policyPhoneNumber: order.customer.phoneNumber, - policyEmail: order.customer.emailAddress + policyFirstName: customer.firstName, + policyLastName: customer.lastName, + policyPhoneNumber: customer.phoneNumber, + policyEmail: customer.emailAddress }, policyNumber: policy.policyNumber, policyZipCode: policy.policyZipCode, noCoverage: policy.noCoverage, policyLookupSuccessful: policy.policyLookupSuccessful, - originalDeductible: order.originalDeductible, - currentDeductible: order.currentDeductible + originalDeductible: this.order.originalDeductible, + currentDeductible: this.order.currentDeductible }, customer: { address: { - streetAddress: order.customer.address.streetAddress, - streetAddress2: order.customer.address.streetAddress2, - city: order.customer.address.city, - state: order.customer.address.state, - zipCode: order.customer.address.zipCode + streetAddress: customer.address.streetAddress, + streetAddress2: customer.address.streetAddress2, + city: customer.address.city, + state: customer.address.state, + zipCode: customer.address.zipCode }, - emailAddress: order.contactInfo.emailAddress, - firstName: order.contactInfo.firstName, - lastName: order.contactInfo.lastName, - phoneNumber: order.contactInfo.phoneNumber, - optInSms: order.contactInfo.requestTextUpdates ?? false + emailAddress: contactInfo.emailAddress, + firstName: contactInfo.firstName, + lastName: contactInfo.lastName, + phoneNumber: contactInfo.phoneNumber, + optInSms: contactInfo.requestTextUpdates ?? false }, lineItems: { glassParts: lineItems.glassParts, @@ -772,36 +763,35 @@ export const useMainStore = defineStore({ }, payment: { InsuranceCoverage: { - isVerified: order.payment.insuranceCoverage.isVerified ?? false, - coverageStatus: order.payment.insuranceCoverage.coverageStatus + isVerified: payment.insuranceCoverage.isVerified ?? false, + coverageStatus: payment.insuranceCoverage.coverageStatus }, - isInsurance: order.payment.isInsurance ?? true, + isInsurance: payment.isInsurance ?? true, parentAccountNumber: this.issConfig.accountNumber }, serviceLocation: { address: { - streetAddress: order.serviceLocation.address, - city: order.serviceLocation.city, - state: order.serviceLocation.state, - zipCode: order.serviceLocation.zipCode, - zipCodeCtu: order.serviceLocation.zipCodeCtu + streetAddress: serviceLocation.address, + city: serviceLocation.city, + state: serviceLocation.state, + zipCode: serviceLocation.zipCode, + zipCodeCtu: serviceLocation.zipCodeCtu }, - techNotes: order.contactInfo.notesForTechnician + techNotes: contactInfo.notesForTechnician }, schedule: { - date: order.schedule?.date, - startTime: order.schedule?.startTime, - endTime: order.schedule?.endTime, - routeCode: order.schedule?.routeCode, - jobMaxMinutes: order.schedule?.jobMaxMinutes + date: schedule?.date, + startTime: schedule?.startTime, + endTime: schedule?.endTime, + routeCode: schedule?.routeCode, + jobMaxMinutes: schedule?.jobMaxMinutes }, - referralDate: order.referralDate, - referralNumber: order.referralNumber?.toString() + referralDate: this.order.referralDate, + referralNumber: this.order.referralNumber?.toString() } }, - // TODO maybe modify additionalSuccessEventDataHandler: (response) => - `Email provided: ${order.customer.emailAddress ? 'true' : 'false'}` + `Email provided: ${customer.emailAddress ? 'true' : 'false'}` }); },