move policy lookup call to welcome-page, navigation from welcome-page

This commit is contained in:
Kroell 2023-05-10 15:04:46 -04:00
parent b344e263d0
commit 3b7dffd82a
4 changed files with 98 additions and 57 deletions

View file

@ -90,13 +90,10 @@ export default {
let resultMap = await settleAllPromises(promiseResultMap); let resultMap = await settleAllPromises(promiseResultMap);
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
}, },
created(){
this.getVehiclesfromPolicyLookup();
},
methods: methods:
{ {
backButtonAction() { backButtonAction() {
@ -124,6 +121,7 @@ export default {
this.$route this.$route
); );
}, },
getPolicyHolderDetailsFromStore() { getPolicyHolderDetailsFromStore() {
return { return {
addressQuestions : addressQuestions :
@ -138,46 +136,6 @@ export default {
lastName : this.mainStore.order.customer.lastName, lastName : this.mainStore.order.customer.lastName,
} }
}, },
async getPolicyLookupResponse(){
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,
}
];
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
return policyLookupResultMap.policyLookupResponse;
},
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;
this.customerQuestions = this.getPolicyHolderDetailsFromStore();
//populate vehicles
this.vehiclesFound= policy.vehicles;
}
}
}
},
}, },
computed:{ computed:{
isCoverageEnabled(){ isCoverageEnabled(){

View file

@ -203,7 +203,8 @@ export default {
mixins: [BaseFormMixin], mixins: [BaseFormMixin],
data() { data() {
return { return {
welcomePageModel: this.getWelcomePageModelFromStore() welcomePageModel: this.getWelcomePageModelFromStore(),
vehiclesFound: [],
}; };
}, },
setup() { setup() {
@ -238,15 +239,81 @@ export default {
{ {
async forwardButtonAction() { async forwardButtonAction() {
this.mainStore.updatePolicyData(this.welcomePageModel); this.mainStore.updatePolicyData(this.welcomePageModel);
return this.navigateForward();
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,
}
];
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
const policyInfo = policyLookupResultMap.policyLookupResponse;
return this.navigateForward(policyInfo);
}, },
navigateForward() { navigateForward(policyInfo) {
this.$router.navigate( const policy = policyInfo.policies?.[0];
this.navigationScenarios.CLICKED_FORWARD,
this.$route // 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 {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES,
this.$route,
{},
{},
this.vehiclesFound
);
}
}, },
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() { getWelcomePageModelFromStore() {
return { return {
policyNumber : this.mainStore.order.policy.policyNumber, policyNumber : this.mainStore.order.policy.policyNumber,
@ -306,7 +373,10 @@ export default {
isPolicyHolderEnabled() isPolicyHolderEnabled()
{ {
return !!this.mainStore.issConfig.disabledFields.policyNumber; return !!this.mainStore.issConfig.disabledFields.policyNumber;
} },
isCoverageEnabled(){
return this.mainStore.issConfig.isCoverageEnabled;
},
}, },
components: { components: {
siteHeader, siteHeader,

View file

@ -6,6 +6,11 @@ const navigationScenarios = {
// Entry // Entry
MOVE_FORWARD_ENTRY_PAGE: "MOVE_FORWARD_ENTRY_PAGE", MOVE_FORWARD_ENTRY_PAGE: "MOVE_FORWARD_ENTRY_PAGE",
// Welcome
CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES: "CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES",
CLICKED_FORWARD_WITH_NO_POLICY: "CLICKED_FORWARD_WITH_NO_POLICY",
CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES: "CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES",
// YMMS // YMMS
SELECTED_YEAR: "SELECTED_YEAR", SELECTED_YEAR: "SELECTED_YEAR",
SELECTED_MAKE: "SELECTED_MAKE", SELECTED_MAKE: "SELECTED_MAKE",
@ -46,8 +51,8 @@ const navigationScenarios = {
//Provider Preference //Provider Preference
CLICKED_FORWARD_WITH_SAFELITE: "CLICKED_FORWARD_WITH_SAFELITE", CLICKED_FORWARD_WITH_SAFELITE: "CLICKED_FORWARD_WITH_SAFELITE",
CLICKED_FORWARD_WITH_TPA_ENABLED: "CLICKED_FORWARD_WITH_TPA_ENABLED", CLICKED_FORWARD_WITH_TPA_ENABLED: "CLICKED_FORWARD_WITH_TPA_ENABLED",
CLICKED_FORWARD_WITH_TPA_DISABLED: "CLICKED_FORWARD_WITH_TPA_DISABLED" CLICKED_FORWARD_WITH_TPA_DISABLED: "CLICKED_FORWARD_WITH_TPA_DISABLED",
CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES: "CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES"
}; };

View file

@ -375,8 +375,16 @@ const routingTable = function(store) {
destinationIssPageValue: issPageValues.WELCOME_PAGE destinationIssPageValue: issPageValues.WELCOME_PAGE
}, },
{ {
scenario: navigationScenarios.CLICKED_FORWARD, scenario: navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES,
destinationIssPageValue: issPageValues.POLICY_VEHICLES
},
{
scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
},
{
scenario: navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES,
destinationIssPageValue: issPageValues.VEHICLE_SELECTION
} }
] ]
}, },