From 072ff844516ca0fb83b1ca26a6d593819d0727f5 Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Thu, 23 May 2024 13:08:18 -0500 Subject: [PATCH] SSR-1167 PR discussions --- src/constants/coverage-type.js | 1 + src/constants/endpoints.js | 2 +- .../coverage-statement/coverage-statement.vue | 16 +-- src/layouts/welcome-page/welcome-page.vue | 93 ++++--------- src/store/index.js | 124 ++++++++++++------ 5 files changed, 119 insertions(+), 117 deletions(-) diff --git a/src/constants/coverage-type.js b/src/constants/coverage-type.js index 258be808..ec136d76 100644 --- a/src/constants/coverage-type.js +++ b/src/constants/coverage-type.js @@ -20,6 +20,7 @@ const coverageType = Object.freeze({ /** * We attempted policy lookup and got a success response * The vehicle policy does not have comprehensive coverage + * No Comp quotes are enabled by the client */ NO_COMP: 3 }); diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 039bb464..4fe98061 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -157,7 +157,7 @@ const endpoints = Object.freeze({ method: 'POST' }, ValidateZip: { - url: `${LOCATION_BASE_URL}/zip`, + url: (zip) => `${LOCATION_BASE_URL}/zip/${zip}`, method: 'GET' }, GooglePlaces: { diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index 4dbad4d8..aa0d38d5 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -327,7 +327,6 @@ export default { const { vehicle, isClaimRegistrationRequired, - isClaimAlreadyRegistered, isPolicyLookupSuccessful, isPendingClaimRegistration } = useMainStore(); @@ -337,7 +336,6 @@ export default { && policyVehicleId != null && policyVehicleId >= 0 && isClaimRegistrationRequired - && !isClaimAlreadyRegistered && isPendingClaimRegistration ); } @@ -365,18 +363,20 @@ export default { return !!useMainStore().vehicle.carId; }, async initializeComponent() { - // TODO this should be determined based on the result of the ITAC price call - // TODO it seems that ITAC now requires claim registration calls. If this call fails - if (this.mainStore.isDeductible && this.deductibleValue > this.totalServicePrice) { - this.mainStore.updateCoverageType(coverageType.ITAC); - } - if (this.shouldRegisterClaim) { await this.mainStore.registerClaim(); } else if (!this.mainStore.isClaimRegistrationRequired) { this.mainStore.updateCoverageStatus(coverageStatuses.VERIFIED); } + // TODO this should be determined based on the result of the ITAC price call + // TODO it seems that ITAC now requires claim registration calls. If this call fails + if (this.mainStore.isVerified + && this.mainStore.isDeductible + && this.deductibleValue > this.totalServicePrice) { + this.mainStore.updateCoverageType(coverageType.ITAC); + } + showIssLoadingModal(false); }, async navigateForward() { diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue index 45c6e3b2..454e6734 100644 --- a/src/layouts/welcome-page/welcome-page.vue +++ b/src/layouts/welcome-page/welcome-page.vue @@ -174,9 +174,6 @@ import states from '@/constants/states'; import globalRules from '@/constants/global-rules'; import routerParams from '@/router/router-constants/router-params'; import MaskaFormattedMasks from '@/constants/maska-masks'; -import globalMethods from '@/global-methods'; -import { endpoints } from '@/constants/endpoints'; -import coverageType from '@/constants/coverage-type'; // define validation rules defineRule( @@ -295,81 +292,35 @@ export default { isDateOfLossDisabled() { return !!this.mainStore.issConfig.disabledFields.dateOfLoss; }, - isCoverageEnabled() { - return this.mainStore.issConfig.isCoverageEnabled; - }, - maxCoverageLookupAttemptsReached() { - return this.mainStore.applicationUser.coverageLookupAttempts >= 11; - }, phoneMask() { return MaskaFormattedMasks.PHONE_NUMBER; } }, methods: { async forwardButtonAction() { - await this.mainStore - .validateZip({ zip: this.welcomePageModel.policyZipCode }) - .then(async (zipInfo) => { - if (zipInfo?.data?.isValid === true) { - this.mainStore.updatePolicyData(this.welcomePageModel); - - this.mainStore.order.serviceLocation.zipCodeCtu = - zipInfo.data.zipCodeCtu?.toString(); - - const billToInfo = await this.getBillToInfo( - this.mainStore.issConfig.parentAccountNumber, - this.mainStore.order.serviceLocation.zipCodeCtu - ); - - if (billToInfo !== null) { - this.mainStore.issConfig.billToAccountNumber = - billToInfo.billToAccountNumber; - this.mainStore.issConfig.itacCashBillToNumber = - billToInfo.itacCashBillToNumber; - this.mainStore.issConfig.itacFnrBillToNumber = - billToInfo.itacFnrBillToNumber; - } - - await this.mainStore - .getDuplicateReferrals() - .catch(() => {}) - .finally(async () => { - if (this.isCoverageEnabled - && !this.maxCoverageLookupAttemptsReached) { - await this.mainStore.getCoveragePolicyInfo() - ?.catch(() => this.mainStore.updateCoverageType(coverageType.NONE)); - } else { - this.mainStore.updateCoverageType(coverageType.NONE); - } - this.navigateForward(); - }); - } else { - this.displayInvalidZipAlert = true; - this.$refs.siteFooter.removeLoader(); - } - }); - }, - async getBillToInfo(parentAccountNumber, providerNumber) { try { - const payload = { - parentAccountNumber: parentAccountNumber.toString(), - providerNumber: providerNumber.toString(), - billToSelectionCriteria: { - typeOfClaim: 'GLASS ONLY', - lineOfBusiness: 'PERSONAL' - } - }; - - const response = await globalMethods.callHttpClient({ - method: endpoints.GetBillToInfo.method, - endpoint: endpoints.GetBillToInfo.url, - payload - }); - - return response.data; - } catch (err) { - console.error(`Error Status Code: ${err.data?.status}: ${err.data?.title}`); - return null; + await this.configureZip(); + this.mainStore.updatePolicyData(this.welcomePageModel); + await this.mainStore.getBillToInfo(); + await this.mainStore.getDuplicateReferrals(); + await this.mainStore.getCoveragePolicyInfo(); + } catch (e) { + console.error(e); + // TODO: Bailout? + } finally { + if (!this.displayInvalidZipAlert) { + this.navigateForward(); + } + } + }, + async configureZip() { + try { + await this.mainStore.validateZip({ zip: this.welcomePageModel.policyZipCode }); + return Promise.resolve(); + } catch (e) { + this.displayInvalidZipAlert = true; + this.$refs.siteFooter.removeLoader(); + return Promise.reject(e); } }, navigateForward() { diff --git a/src/store/index.js b/src/store/index.js index 4765dcbd..757f3c07 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -523,13 +523,20 @@ export const useMainStore = defineStore({ }; } }, - getCoveragePolicyInfo() { - const { order } = this; + async getCoveragePolicyInfo() { + const { order, issConfig, applicationUser } = this; const { policy } = order; + + if (issConfig.isCoverageEnabled && applicationUser.coverageLookupAttempts > 10) { + this.updateCoverageType(coverageType.NONE); + return Promise.resolve(); + } + this.applicationUser.coverageAttempts += 1; console.log(`Coverage lookup attempt #${this.applicationUser.coverageAttempts}. Max attempts allowed: 10.`); - return new Promise((resolve, reject) => { - globalMethods.callHttpClient({ + + try { + const response = await globalMethods.callHttpClient({ method: endpoints.CoveragePolicyInfo.method, endpoint: endpoints.CoveragePolicyInfo.url, payload: { @@ -539,35 +546,35 @@ export const useMainStore = defineStore({ zipCode: policy.policyZipCode, referralCorrelationId: order.referralCorrelationId } - }).then((r) => { - const responsePolicy = r?.data?.policies?.[0]; - if (responsePolicy) { - this.updateCoverageType(coverageType.Deductible); - const insured = responsePolicy.insureds?.[0]; - - // populate policy holder details from policy lookup - order.customer.address.streetAddress = insured?.address; - order.customer.address.city = insured?.city; - order.customer.address.state = insured?.state; - order.customer.address.zipCode = insured?.zipCode?.toString(); - order.customer.firstName = insured?.firstName; - order.customer.lastName = insured?.lastName; - - // populate additional fields - order.serviceLocation.zipCode = insured?.zipCode?.toString(); - order.policy.policyData = responsePolicy.policyData; - - // populate vehicles - order.policy.vehicles = responsePolicy.vehicles ?? []; - } else { - this.updateCoverageType(coverageType.NONE); - } - return resolve(r); - }).catch((error) => { - this.updateCoverageType(coverageType.NONE); - return reject(error); }); - }); + + const responsePolicy = response?.data?.policies?.[0]; + if (responsePolicy) { + this.updateCoverageType(coverageType.Deductible); + const insured = responsePolicy.insureds?.[0]; + + // populate policy holder details from policy lookup + order.customer.address.streetAddress = insured?.address; + order.customer.address.city = insured?.city; + order.customer.address.state = insured?.state; + order.customer.address.zipCode = insured?.zipCode?.toString(); + order.customer.firstName = insured?.firstName; + order.customer.lastName = insured?.lastName; + + // populate additional fields + order.serviceLocation.zipCode = insured?.zipCode?.toString(); + order.policy.policyData = responsePolicy.policyData; + + // populate vehicles + order.policy.vehicles = responsePolicy.vehicles ?? []; + } else { + this.updateCoverageType(coverageType.NONE); + } + return Promise.resolve(); + } catch (e) { + this.updateCoverageType(coverageType.NONE); + return Promise.reject(e); + } }, updateCoverageStatus(status) { this.order.insuranceCoverage.coverageStatus = status; @@ -682,7 +689,7 @@ export const useMainStore = defineStore({ status: this.order.policy.status, originalDeductible: this.order.originalDeductible, currentDeductible: this.order.currentDeductible, - noCoverage: this.isNoComp, + noCoverage: false, isRepair: this.order.damage.isRepair, policyNumber: this.order.policy.policyNumber, insuredFirstName: this.order.customer.firstName, @@ -2259,10 +2266,53 @@ export const useMainStore = defineStore({ }, async validateZip({ zip }) { - return await globalMethods.callHttpClient({ - method: endpoints.ValidateZip.method, - endpoint: `${endpoints.ValidateZip.url}/${zip}` - }); + try { + const response = await globalMethods.callHttpClient({ + method: endpoints.ValidateZip.method, + endpoint: endpoints.ValidateZip.url(zip) + }); + const zipInfo = response.data; + if (zipInfo?.isValid === true) { + this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu; + return Promise.resolve(); + } + + return Promise.reject(new Error('Invalid Zip Info')); + } catch (e) { + return Promise.reject(e); + } + }, + + async getBillToInfo() { + const { order, issConfig } = this; + try { + const payload = { + parentAccountNumber: issConfig.parentAccountNumber.toString(), + providerNumber: order.serviceLocation.zipCodeCtu.toString(), + billToSelectionCriteria: { + typeOfClaim: 'GLASS ONLY', + lineOfBusiness: 'PERSONAL' + } + }; + + const response = await globalMethods.callHttpClient({ + method: endpoints.GetBillToInfo.method, + endpoint: endpoints.GetBillToInfo.url, + payload + }); + + const billToInfo = response.data; + if (billToInfo != null) { + issConfig.billToAccountNumber = billToInfo.billToAccountNumber; + issConfig.itacCashBillToNumber = billToInfo.itacCashBillToNumber; + issConfig.itacFnrBillToNumber = billToInfo.itacFnrBillToNumber; + return Promise.resolve(); + } + + return Promise.reject(new Error('Invalid billToInfo')); + } catch (e) { + return Promise.reject(e); + } }, async validateClientTag(clientTag) {