SSR-1167 PR discussions

This commit is contained in:
Josh Dassinger 2024-05-23 13:08:18 -05:00
parent 80873d77d2
commit 072ff84451
5 changed files with 119 additions and 117 deletions

View file

@ -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
});

View file

@ -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: {

View file

@ -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() {

View file

@ -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() {

View file

@ -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) {