refactor WIP
This commit is contained in:
parent
c8293fde28
commit
c5e051874d
1 changed files with 59 additions and 62 deletions
|
|
@ -239,47 +239,52 @@ export default {
|
|||
{
|
||||
async forwardButtonAction() {
|
||||
this.mainStore.updatePolicyData(this.welcomePageModel);
|
||||
|
||||
const policyLookupResponse = this.mainStore.getCoveragePolicyInfo({
|
||||
accountNumber:this.mainStore.order.accountNumber.toString(),
|
||||
policyNumber:this.mainStore.order.policy.policyNumber,
|
||||
dateOfLoss:this.mainStore.order.policy.dateOfLoss
|
||||
});
|
||||
|
||||
// Settle promises and get results
|
||||
const promisePolicyLookupResultMap = [
|
||||
{
|
||||
resultKey: "policyLookupResponse",
|
||||
promise: policyLookupResponse,
|
||||
|
||||
//call coverage policy lookup if isCoverageEnabled flag enabled
|
||||
if (this.isCoverageEnabled) {
|
||||
const policyLookupResponse = useMainStore().getCoveragePolicyInfo({
|
||||
accountNumber:this.mainStore.order.accountNumber.toString(),
|
||||
policyNumber:this.mainStore.order.policy.policyNumber,
|
||||
dateOfLoss:this.mainStore.order.policy.dateOfLoss
|
||||
});
|
||||
|
||||
// Settle promises and get results
|
||||
const promisePolicyLookupResultMap = [
|
||||
{
|
||||
resultKey: "policyLookupResponse",
|
||||
promise: policyLookupResponse,
|
||||
}
|
||||
];
|
||||
|
||||
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
|
||||
const policyInfo = policyLookupResultMap.policyLookupResponse;
|
||||
|
||||
// if policy lookup fails, move the user forward
|
||||
if (!policyInfo) {
|
||||
this.navigateForward();
|
||||
}
|
||||
];
|
||||
|
||||
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
|
||||
const policyInfo = policyLookupResultMap.policyLookupResponse;
|
||||
|
||||
return this.navigateForward(policyInfo);
|
||||
|
||||
const policy = policyInfo.policies?.[0];
|
||||
if (policy) {
|
||||
//populate policy holder details from policy lookup
|
||||
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
||||
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
||||
this.mainStore.order.customer.address.state = policy.insureds?.[0]?.state;
|
||||
this.mainStore.order.customer.address.zipCode = policy.insureds?.[0]?.zipCode;
|
||||
this.mainStore.order.customer.firstName = policy.insureds?.[0]?.firstName;
|
||||
this.mainStore.order.customer.lastName = policy.insureds?.[0]?.lastName;
|
||||
|
||||
//populate vehicles
|
||||
this.vehiclesFound = policy.vehicles;
|
||||
}
|
||||
return this.navigateForward(policy);
|
||||
}
|
||||
return this.navigateForward();
|
||||
},
|
||||
|
||||
navigateForward(policyInfo) {
|
||||
const policy = policyInfo.policies?.[0];
|
||||
|
||||
// if policy lookup is unsuccessful, navigate to policy-holder-details page
|
||||
if (!policy) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
|
||||
this.$route
|
||||
);
|
||||
}
|
||||
// if policy lookup is successful, but no vehicles are associated with the policy
|
||||
// navigate to vehicle-selection page (manual entry)
|
||||
else if (!this.vehiclesFound) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES,
|
||||
this.$route
|
||||
);
|
||||
}
|
||||
// if policy lookup is successful and vehicles are found, navigate to
|
||||
else {
|
||||
navigateForward(policy) {
|
||||
// if policy lookup is successful and vehicles are found, navigate to policy-vehicles page
|
||||
if (policy && this.vehiclesFound) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES,
|
||||
this.$route,
|
||||
|
|
@ -288,31 +293,23 @@ export default {
|
|||
this.vehiclesFound
|
||||
);
|
||||
}
|
||||
// if policy lookup is successful, but no vehicles are associated with the policy
|
||||
// navigate to vehicle-selection page (manual entry)
|
||||
else if (policy && !this.vehiclesFound) {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES,
|
||||
this.$route
|
||||
);
|
||||
}
|
||||
// if policy lookup is unsuccessful, navigate to policy-holder-details page
|
||||
else {
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
|
||||
this.$route
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
async getVehiclesfromPolicyLookup()
|
||||
{
|
||||
//call coverage policy lookup if isCoverageEnabled flag enabled
|
||||
if (this.isCoverageEnabled){
|
||||
const policyLookupResponse = await this.getPolicyLookupResponse();
|
||||
if (policyLookupResponse !== null){
|
||||
var policy = policyLookupResponse.policies?.[0];
|
||||
if (policy !== null){
|
||||
//populate policy holder details from policy lookup
|
||||
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
||||
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
||||
this.mainStore.order.customer.address.state = policy.insureds?.[0]?.state;
|
||||
this.mainStore.order.customer.address.zipCode = policy.insureds?.[0]?.zipCode;
|
||||
this.mainStore.order.customer.firstName = policy.insureds?.[0]?.firstName;
|
||||
this.mainStore.order.customer.lastName = policy.insureds?.[0]?.lastName;
|
||||
|
||||
//populate vehicles
|
||||
this.vehiclesFound = policy.vehicles;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getWelcomePageModelFromStore() {
|
||||
return {
|
||||
policyNumber: this.mainStore.order.policy.policyNumber,
|
||||
|
|
|
|||
Loading…
Reference in a new issue