diff --git a/src/helpers/policy-vehicle-helper.js b/src/helpers/policy-vehicle-helper.js new file mode 100644 index 00000000..69a80e74 --- /dev/null +++ b/src/helpers/policy-vehicle-helper.js @@ -0,0 +1,23 @@ +import endorsementOptions from '@/constants/endorsement-options'; + +export function noCoverageForSelectedVehicle(vehicle) { + return (vehicle?.coverages?.length ?? 0) === 0; +} +export function deductibleForSelectedVehicle(vehicle) { + if (!vehicle) { + return undefined; + } + + return vehicle.coverages?.length ?? false + ? vehicle?.coverages[0].deductible + : 0; +} +export function endorsementsForSelectedVehicle(vehicle) { + if (vehicle?.endorsements?.length > 0) { + return vehicle.endorsements; + } + return []; +} +export function repairWaivedForSelectedVehicle(vehicle) { + return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false; +} diff --git a/src/helpers/policy-vehicle-helper.spec.js b/src/helpers/policy-vehicle-helper.spec.js new file mode 100644 index 00000000..be3411b3 --- /dev/null +++ b/src/helpers/policy-vehicle-helper.spec.js @@ -0,0 +1,205 @@ +import { + deductibleForSelectedVehicle, + endorsementsForSelectedVehicle, + noCoverageForSelectedVehicle, + repairWaivedForSelectedVehicle +} from '@/helpers/policy-vehicle-helper'; +import { getRandomInt, getRandomString } from '@/helpers/data-generation'; +import endorsementOptions from '@/constants/endorsement-options'; + +describe('policy vehicle helper', () => { + describe('noCoverageForSelectedVehicle function', () => { + it('Null vehicle => returns true', async () => { + // Arrange + const vehicle = null; + + // Act + const result = noCoverageForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeTruthy(); + }); + + it('Empty vehicle coverages list => returns true', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + coverages: [] + }; + + // Act + const result = noCoverageForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeTruthy(); + }); + + it('Non-empty vehicle coverages list => returns false', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + coverages: [ + { + deductible: 0 + } + ] + }; + + // Act + const result = deductibleForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeFalsy(); + }); + }); + + describe('deductibleForSelectedVehicle function', () => { + it('Null vehicle => returns undefined', async () => { + // Arrange + const vehicle = null; + + // Act + const result = deductibleForSelectedVehicle(vehicle); + + // Assert + expect(result).toBe(undefined); + }); + + it('Vehicle match with empty coverages list => 0 returned', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + coverages: [] + }; + + // Act + const result = deductibleForSelectedVehicle(vehicle); + + // Assert + expect(result).toBe(0); + }); + + it('Coverages list non empty => deductible from first coverage returned', async () => { + // Arrange + const firstDeductible = getRandomInt(1, 1000); + const vehicle = { + vin: getRandomString(17, 17), + coverages: [ + { + deductible: firstDeductible + }, + { + deductible: getRandomInt(1, 1000) + } + ] + }; + + // Act + const result = deductibleForSelectedVehicle(vehicle); + + // Assert + expect(result).toBe(firstDeductible); + }); + }); + + describe('repairWaivedForSelectedVehicle function', () => { + it('Null vehicle => returns false', async () => { + // Arrange + const vehicle = null; + + // Act + const result = repairWaivedForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeFalsy(); + }); + + it('Endorsements list empty => false returned', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + endorsements: [] + }; + + // Act + const result = repairWaivedForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeFalsy(); + }); + + it('Endorsements list non-empty, not containing repair waived => false returned', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD] + }; + + // Act + const result = repairWaivedForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeFalsy(); + }); + + it('Endorsements list contains repair waived => true returned', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + endorsements: [ + endorsementOptions.EDUCATOR, + endorsementOptions.REPAIR_WAIVED, + endorsementOptions.PARKING_GUARD + ] + }; + + // Act + const result = repairWaivedForSelectedVehicle(vehicle); + + // Assert + expect(result).toBeTruthy(); + }); + }); + + describe('endorsementsForSelectedVehicle function', () => { + it('Null vehicle => returns empty array', async () => { + // Arrange + const vehicle = null; + + // Act + const result = endorsementsForSelectedVehicle(vehicle); + + // Assert + expect(result).toStrictEqual([]); + }); + + it('Null endorsements => returns empty array', async () => { + // Arrange + const vehicle = { + vin: getRandomString(17, 17), + endorsements: null + }; + + // Act + const result = endorsementsForSelectedVehicle(vehicle); + + // Assert + expect(result).toStrictEqual([]); + }); + + it('Endorsements list non-empty, not containing repair waived => false returned', async () => { + // Arrange + const endorsements = [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]; + const vehicle = { + vin: getRandomString(17, 17), + endorsements + }; + + // Act + const result = endorsementsForSelectedVehicle(vehicle); + + // Assert + expect(result).toStrictEqual(endorsements); + }); + }); +}); diff --git a/src/layouts/coverage-statement/coverage-statement.spec.js b/src/layouts/coverage-statement/coverage-statement.spec.js index e4debdf7..a597b7f9 100644 --- a/src/layouts/coverage-statement/coverage-statement.spec.js +++ b/src/layouts/coverage-statement/coverage-statement.spec.js @@ -829,7 +829,7 @@ describe.skip('coverageStatement.vue', () => { describe('coverageStatement.vue-working', () => { describe('ITAC flag', () => { - test('ITAC flag updated once component is initialized', () => { + test('ITAC flag updated once component is initialized', async () => { // Arrange const mainInitialState = { order: { @@ -838,7 +838,10 @@ describe('coverageStatement.vue-working', () => { } } }; - const { wrapper } = getMountedComponent(mainInitialState); + const mockStoreActions = () => { + useMainStore().getPriceOrderItems = jest.fn().mockImplementation(() => Promise.resolve([])); + }; + const { wrapper } = getMountedComponent(mainInitialState, {}, mockStoreActions); // Act wrapper.vm.initializeComponent(); diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index 1c88dd4b..9168feb0 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -102,10 +102,12 @@ describe('policy-vehicles.vue', () => { const { wrapper } = setupMocks({}); const vin = getRandomString(17, 17); + const policyVehicle = { vin }; await wrapper.setData({ selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { vin } + policyVehicle ], policyVinFound: true }); @@ -202,13 +204,15 @@ describe('policy-vehicles.vue', () => { const vin = getRandomString(17, 17); const endorsements = ['Parking Guard']; + const policyVehicle = { + vin, + endorsements + }; await wrapper.setData({ selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements - } + policyVehicle ] }); @@ -342,12 +346,14 @@ describe('policy-vehicles.vue', () => { // Arrange const selectedVin = getRandomString(17, 17); const otherVin = getRandomString(17, 17); + const policyVehicle = { + vin: otherVin + }; const testValues = { selectedVehicleVin: selectedVin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin: otherVin - } + policyVehicle ] }; @@ -361,13 +367,15 @@ describe('policy-vehicles.vue', () => { it('Coverages list empty => true', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + coverages: [] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - coverages: [] - } + policyVehicle ] }; @@ -381,17 +389,19 @@ describe('policy-vehicles.vue', () => { it('Coverages list non-empty => false', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + coverages: [ + { + deductible: 0 + } + ] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - coverages: [ - { - deductible: 0 - } - ] - } + policyVehicle ] }; @@ -410,6 +420,7 @@ describe('policy-vehicles.vue', () => { const otherVin = getRandomString(17, 17); const testValues = { selectedVehicleVin: selectedVin, + selectedPolicyVehicle: null, policyVehicles: [ { vin: otherVin @@ -427,13 +438,15 @@ describe('policy-vehicles.vue', () => { it('Vehicle match with empty coverages list => 0 returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + coverages: [] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - coverages: [] - } + policyVehicle ] }; @@ -449,20 +462,22 @@ describe('policy-vehicles.vue', () => { const vin = getRandomString(17, 17); const firstDeductible = getRandomInt(1, 1000); const secondDeductible = getRandomInt(1, 1000); + const policyVehicle = { + vin, + coverages: [ + { + deductible: firstDeductible + }, + { + deductible: secondDeductible + } + ] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - coverages: [ - { - deductible: firstDeductible - }, - { - deductible: secondDeductible - } - ] - } + policyVehicle ] }; @@ -481,6 +496,7 @@ describe('policy-vehicles.vue', () => { const otherVin = getRandomString(17, 17); const testValues = { selectedVehicleVin: selectedVin, + selectedPolicyVehicle: null, policyVehicles: [ { vin: otherVin @@ -498,13 +514,15 @@ describe('policy-vehicles.vue', () => { it('Endorsements list empty => false returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + endorsements: [] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements: [] - } + policyVehicle ] }; @@ -518,13 +536,15 @@ describe('policy-vehicles.vue', () => { it('Endorsements list non-empty, not containing repair waived => false returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD] - } + policyVehicle ] }; @@ -538,17 +558,19 @@ describe('policy-vehicles.vue', () => { it('Endorsements list contains repair waived => true returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + endorsements: [ + endorsementOptions.EDUCATOR, + endorsementOptions.REPAIR_WAIVED, + endorsementOptions.PARKING_GUARD + ] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements: [ - endorsementOptions.EDUCATOR, - endorsementOptions.REPAIR_WAIVED, - endorsementOptions.PARKING_GUARD - ] - } + policyVehicle ] }; @@ -564,6 +586,7 @@ describe('policy-vehicles.vue', () => { it('policyVehicles is null => empty endorsements array returned', () => { // Arrange const testValues = { + selectedPolicyVehicle: null, policyVehicles: null }; @@ -578,6 +601,7 @@ describe('policy-vehicles.vue', () => { it('policyVehicles is empty => empty endorsements array returned', () => { // Arrange const testValues = { + selectedPolicyVehicle: null, policyVehicles: [] }; @@ -595,6 +619,7 @@ describe('policy-vehicles.vue', () => { const otherVin = getRandomString(17, 17); const testValues = { selectedVehicleVin: selectedVin, + selectedPolicyVehicle: null, policyVehicles: [ { vin: otherVin @@ -613,13 +638,15 @@ describe('policy-vehicles.vue', () => { it('vehicle VIN match with endorsements null => empty endorsements array returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + endorsements: null + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements: null - } + policyVehicle ] }; @@ -634,13 +661,15 @@ describe('policy-vehicles.vue', () => { it('vehicle VIN match with empty endorsements => empty endorsements array returned', () => { // Arrange const vin = getRandomString(17, 17); + const policyVehicle = { + vin, + endorsements: [] + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements: [] - } + policyVehicle ] }; @@ -656,13 +685,15 @@ describe('policy-vehicles.vue', () => { // Arrange const vin = getRandomString(17, 17); const endorsements = [getRandomString(10, 20)]; + const policyVehicle = { + vin, + endorsements + }; const testValues = { selectedVehicleVin: vin, + selectedPolicyVehicle: policyVehicle, policyVehicles: [ - { - vin, - endorsements - } + policyVehicle ] }; @@ -694,25 +725,4 @@ describe('policy-vehicles.vue', () => { // Assert expect(wrapper.vm.selectedVehicleVin).toBe(vin); }); - - test('load session vehicle is auto-selected if vehicle is on policy', async () => { - // Arrange - const vin = getRandomString(17, 17); - useMainStore().order = { - policy: { - vehicles: [{ vin }] - }, - vehicle: { - vin - } - }; - - const { wrapper } = setupMocks(); - - // Act - await wrapper.vm.$nextTick(); - - // Assert - expect(wrapper.vm.selectedVehicleVin).toBe(vin); - }); }); diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index c553066c..915b97e8 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -53,8 +53,12 @@ import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js'; import endorsementOptions from '@/constants/endorsement-options.js'; import globalRules from '@/constants/global-rules.js'; import { useMainStore } from '@/store/index.js'; -import bailoutCode from '@/constants/bailoutCode'; import bailoutMessage from '@/constants/bailoutMessage'; +import { + deductibleForSelectedVehicle, endorsementsForSelectedVehicle, + noCoverageForSelectedVehicle, + repairWaivedForSelectedVehicle +} from '@/helpers/policy-vehicle-helper'; export default { name: 'policy-vehicles', @@ -82,6 +86,7 @@ export default { return { policyVehicles, selectedVehicleVin: '', + selectedPolicyVehicle: null, displayGeneric: true, policyVinFound: true, rules: { @@ -108,33 +113,16 @@ export default { return mappedData; }, noCoverageForSelectedVehicle() { - const vehicle = this.policyVehicles?.find((policyVehicle) => - policyVehicle.vin === this.selectedVehicleVin); - return (vehicle?.coverages?.length ?? 0) === 0; + return noCoverageForSelectedVehicle(this.selectedPolicyVehicle); }, deductibleForSelectedVehicle() { - const vehicle = this.policyVehicles?.find((policyVehicle) => - policyVehicle?.vin === this.selectedVehicleVin); - if (!vehicle) { - return undefined; - } - - return vehicle.coverages?.length ?? false - ? vehicle?.coverages[0].deductible - : 0; + return deductibleForSelectedVehicle(this.selectedPolicyVehicle); }, endorsementsForSelectedVehicle() { - const vehicle = this.policyVehicles?.find((policyVehicle) => - policyVehicle?.vin === this.selectedVehicleVin); - if (vehicle?.endorsements?.length > 0) { - return vehicle.endorsements; - } - return []; + return endorsementsForSelectedVehicle(this.selectedPolicyVehicle); }, repairWaivedForSelectedVehicle() { - const vehicle = this.policyVehicles?.find((policyVehicle) => - policyVehicle.vin === this.selectedVehicleVin); - return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false; + return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle); }, selectedVehicle() { const vehicle = this.mainStore.lookupVehicleByVin(this.selectedVehicleVin); @@ -147,6 +135,7 @@ export default { // clear previously selected vehicle and image this.mainStore.resetVehicleState(); this.displayGeneric = true; + this.selectedPolicyVehicle = null; } else { // get vehicle details from selected VIN const vehicle = await this.lookupVehicleByVin(value); @@ -155,12 +144,14 @@ export default { if (vehicle?.error === true) { this.mainStore.resetVehicleState(); this.displayGeneric = true; + this.selectedPolicyVehicle = null; return; } if (vehicle) { // save selected vehicle to the store this.mainStore.updateVehicle(vehicle.data); this.displayGeneric = false; + this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value); } } } diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 9e876ea5..d20f59cd 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -423,7 +423,7 @@ const routingTable = () => [ }, { scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, - destinationIssPageValue: issPageValues.POLICY_VEHICLES + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE }, { scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE, diff --git a/src/store/index.js b/src/store/index.js index f16f58e7..1b969be8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -14,6 +14,11 @@ import coverageStatuses from '@/constants/coverage-statuses'; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper'; import { paymentMethods } from '@/constants/payment-method-constants'; +import { + deductibleForSelectedVehicle, endorsementsForSelectedVehicle, + noCoverageForSelectedVehicle, + repairWaivedForSelectedVehicle +} from '@/helpers/policy-vehicle-helper'; const storeId = 'main'; @@ -1192,11 +1197,12 @@ export const useMainStore = defineStore({ }); }, - loadSession() { + async loadSession() { const { applicationUser, order, issConfig } = this; // TODO how to get savedSessionId for a duplicate referral? - return new Promise((resolve, reject) => { - globalMethods.callHttpClient({ + + try { + const response = await globalMethods.callHttpClient({ method: endpoints.LoadSession.method, endpoint: endpoints.LoadSession.url, payload: { @@ -1206,67 +1212,81 @@ export const useMainStore = defineStore({ parentAccountNumber: issConfig.parentAccountNumber, referralCorrelationId: order.referralCorrelationId } - }).then((response) => { - const { data } = response; - if (!data) { - // TODO how should we handle this case? - return resolve(data); - } + }); + const { data } = response; + if (!data) { + // TODO how should we handle this case? + return respone; + } - applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId; - applicationUser.experiments = data.applicationUser?.experiments ?? []; - applicationUser.savedSessionId = data.applicationUser?.savedSessionId; + applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId; + applicationUser.experiments = data.applicationUser?.experiments ?? []; + applicationUser.savedSessionId = data.applicationUser?.savedSessionId; - if (order.policy.policyLookupSuccessful) { - order.customer.emailAddress = data.customer?.emailAddress; - order.customer.firstName = data.customer?.firstName; - order.customer.lastName = data.customer?.lastName; - order.customer.phoneNumber = data?.customer?.phoneNumber; + if (order.policy.policyLookupSuccessful) { + order.customer.emailAddress = data.customer?.emailAddress; + order.customer.firstName = data.customer?.firstName; + order.customer.lastName = data.customer?.lastName; + order.customer.phoneNumber = data?.customer?.phoneNumber; - order.customer.address.streetAddress = data.customer?.address?.streetAddress; - order.customer.address.streetAddress2 = data.customer?.address?.streetAddress2; - order.customer.address.city = data.customer?.address?.city; - order.customer.address.state = data.customer?.address?.state; - order.customer.address.zipCode = data.customer?.address?.zipCode; + order.customer.address.streetAddress = data.customer?.address?.streetAddress; + order.customer.address.streetAddress2 = data.customer?.address?.streetAddress2; + order.customer.address.city = data.customer?.address?.city; + order.customer.address.state = data.customer?.address?.state; + order.customer.address.zipCode = data.customer?.address?.zipCode; - order.contactInfo.firstName = data?.customer?.firstName; - order.contactInfo.lastName = data?.customer?.lastName; - order.contactInfo.emailAddress = data?.customer?.emailAddress; - order.contactInfo.phoneNumber = data?.customer?.phoneNumber; - order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn; + order.contactInfo.firstName = data?.customer?.firstName; + order.contactInfo.lastName = data?.customer?.lastName; + order.contactInfo.emailAddress = data?.customer?.emailAddress; + order.contactInfo.phoneNumber = data?.customer?.phoneNumber; + order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn; - order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified; - order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus; - order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber; + order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified; + order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus; + order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber; - if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) { - order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber; - if (data.vehicle.vin) { - const vehicle = order.policy.vehicles.find((v) => v.vin === data.vehicle.vin); - if (vehicle) { - order.vehicle.vin = data.vehicle.vin; + if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) { + order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber; + if (data.vehicle.vin) { + const vehicle = order.policy.vehicles.find((v) => v.vin === data.vehicle.vin); + if (vehicle) { + const vehicleResponse = await this.lookupVehicleByVin(vehicle.vin); + if (vehicleResponse) { + Object.assign( + vehicleResponse.data, + { + policyVehicleId: vehicle.id, + vin: vehicle.vin, + noCoverage: noCoverageForSelectedVehicle(vehicle), + deductible: deductibleForSelectedVehicle(vehicle), + repairWaived: repairWaivedForSelectedVehicle(vehicle), + endorsements: endorsementsForSelectedVehicle(vehicle) + } + ); + this.updateVehicle(vehicleResponse.data); } } - - order.vehicle.year = data.vehicle.year; - order.vehicle.make = data.vehicle.make; - order.vehicle.model = data.vehicle.model; - order.vehicle.style = data.vehicle.style; } - } - order.referralNumber = data?.referralNumber; - order.referralDate = data?.referralDate; - order.referralCorrelationId = data?.referralCorrelationId; - order.referralSequenceNumber = data?.referralSequenceNumber; - order.eon = data?.eon; - order.loadedFromDupeCheck = true; - order.loadedSessionClearedPreviousData = false; - return resolve(data); - }, (error) => { - reject(error); - }); - }); + order.vehicle.year = data.vehicle.year; + order.vehicle.make = data.vehicle.make; + order.vehicle.model = data.vehicle.model; + order.vehicle.style = data.vehicle.style; + } + } + + order.referralNumber = data?.referralNumber; + order.referralDate = data?.referralDate; + order.referralCorrelationId = data?.referralCorrelationId; + order.referralSequenceNumber = data?.referralSequenceNumber; + order.eon = data?.eon; + order.loadedFromDupeCheck = true; + order.loadedSessionClearedPreviousData = false; + return data; + } catch (ex) { + // TODO how should we handle this case? + throw ex; + } }, setSaveSessionPromise(promise) { @@ -1425,7 +1445,7 @@ export const useMainStore = defineStore({ // These could be undefined this.order.policy.noCoverage = vehicle.noCoverage; - if (this.order.payment.insuranceCoverage.coverageStatus === coverageStatuses.PENDING) { + if (!this.order.payment.insuranceCoverage.claimNumber) { this.order.payment.insuranceCoverage.coverageStatus = vehicle.noCoverage ? coverageStatuses.NO_COMP : coverageStatuses.PENDING;