diff --git a/src/layouts/policy-holder-details/policy-holder-details.vue b/src/layouts/policy-holder-details/policy-holder-details.vue index 8b18a1a3..46789bfa 100644 --- a/src/layouts/policy-holder-details/policy-holder-details.vue +++ b/src/layouts/policy-holder-details/policy-holder-details.vue @@ -90,13 +90,10 @@ export default { let resultMap = await settleAllPromises(promiseResultMap); next((vm) => { - vm.setCmsContent(resultMap.cmsContent); + vm.setCmsContent(resultMap.cmsContent); }); }, - created(){ - this.getVehiclesfromPolicyLookup(); - }, methods: { backButtonAction() { @@ -124,6 +121,7 @@ export default { this.$route ); }, + getPolicyHolderDetailsFromStore() { return { addressQuestions : @@ -137,47 +135,7 @@ export default { firstName : this.mainStore.order.customer.firstName, 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:{ isCoverageEnabled(){ diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue index 417b00d4..1d9d2703 100644 --- a/src/layouts/welcome-page/welcome-page.vue +++ b/src/layouts/welcome-page/welcome-page.vue @@ -203,7 +203,8 @@ export default { mixins: [BaseFormMixin], data() { return { - welcomePageModel: this.getWelcomePageModelFromStore() + welcomePageModel: this.getWelcomePageModelFromStore(), + vehiclesFound: [], }; }, setup() { @@ -238,15 +239,81 @@ export default { { async forwardButtonAction() { 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() { - this.$router.navigate( - this.navigationScenarios.CLICKED_FORWARD, - this.$route - ); + 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 { + 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() { return { policyNumber : this.mainStore.order.policy.policyNumber, @@ -306,7 +373,10 @@ export default { isPolicyHolderEnabled() { return !!this.mainStore.issConfig.disabledFields.policyNumber; - } + }, + isCoverageEnabled(){ + return this.mainStore.issConfig.isCoverageEnabled; + }, }, components: { siteHeader, diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 64fd8933..cb854e26 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -6,6 +6,11 @@ const navigationScenarios = { // Entry 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 SELECTED_YEAR: "SELECTED_YEAR", SELECTED_MAKE: "SELECTED_MAKE", @@ -46,8 +51,8 @@ const navigationScenarios = { //Provider Preference CLICKED_FORWARD_WITH_SAFELITE: "CLICKED_FORWARD_WITH_SAFELITE", 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" }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index e6c25ae6..f82d26d5 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -375,9 +375,17 @@ const routingTable = function(store) { 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 - } + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES, + destinationIssPageValue: issPageValues.VEHICLE_SELECTION + } ] }, {