SSR 512 - Skip policy vehicle page when loading session with policy vehicle

This commit is contained in:
Josh Dassinger 2024-02-29 09:01:26 -06:00
parent 3dc288ae5c
commit 238879ea99
7 changed files with 416 additions and 164 deletions

View file

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

View file

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

View file

@ -829,7 +829,7 @@ describe.skip('coverageStatement.vue', () => {
describe('coverageStatement.vue-working', () => { describe('coverageStatement.vue-working', () => {
describe('ITAC flag', () => { describe('ITAC flag', () => {
test('ITAC flag updated once component is initialized', () => { test('ITAC flag updated once component is initialized', async () => {
// Arrange // Arrange
const mainInitialState = { const mainInitialState = {
order: { 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 // Act
wrapper.vm.initializeComponent(); wrapper.vm.initializeComponent();

View file

@ -102,10 +102,12 @@ describe('policy-vehicles.vue', () => {
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = { vin };
await wrapper.setData({ await wrapper.setData({
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ vin } policyVehicle
], ],
policyVinFound: true policyVinFound: true
}); });
@ -202,13 +204,15 @@ describe('policy-vehicles.vue', () => {
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const endorsements = ['Parking Guard']; const endorsements = ['Parking Guard'];
const policyVehicle = {
vin,
endorsements
};
await wrapper.setData({ await wrapper.setData({
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements
}
] ]
}); });
@ -342,12 +346,14 @@ describe('policy-vehicles.vue', () => {
// Arrange // Arrange
const selectedVin = getRandomString(17, 17); const selectedVin = getRandomString(17, 17);
const otherVin = getRandomString(17, 17); const otherVin = getRandomString(17, 17);
const policyVehicle = {
vin: otherVin
};
const testValues = { const testValues = {
selectedVehicleVin: selectedVin, selectedVehicleVin: selectedVin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin: otherVin
}
] ]
}; };
@ -361,13 +367,15 @@ describe('policy-vehicles.vue', () => {
it('Coverages list empty => true', () => { it('Coverages list empty => true', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: []
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
coverages: []
}
] ]
}; };
@ -381,17 +389,19 @@ describe('policy-vehicles.vue', () => {
it('Coverages list non-empty => false', () => { it('Coverages list non-empty => false', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: [
{
deductible: 0
}
]
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
coverages: [
{
deductible: 0
}
]
}
] ]
}; };
@ -410,6 +420,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17); const otherVin = getRandomString(17, 17);
const testValues = { const testValues = {
selectedVehicleVin: selectedVin, selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [ policyVehicles: [
{ {
vin: otherVin vin: otherVin
@ -427,13 +438,15 @@ describe('policy-vehicles.vue', () => {
it('Vehicle match with empty coverages list => 0 returned', () => { it('Vehicle match with empty coverages list => 0 returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
coverages: []
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
coverages: []
}
] ]
}; };
@ -449,20 +462,22 @@ describe('policy-vehicles.vue', () => {
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const firstDeductible = getRandomInt(1, 1000); const firstDeductible = getRandomInt(1, 1000);
const secondDeductible = getRandomInt(1, 1000); const secondDeductible = getRandomInt(1, 1000);
const policyVehicle = {
vin,
coverages: [
{
deductible: firstDeductible
},
{
deductible: secondDeductible
}
]
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
coverages: [
{
deductible: firstDeductible
},
{
deductible: secondDeductible
}
]
}
] ]
}; };
@ -481,6 +496,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17); const otherVin = getRandomString(17, 17);
const testValues = { const testValues = {
selectedVehicleVin: selectedVin, selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [ policyVehicles: [
{ {
vin: otherVin vin: otherVin
@ -498,13 +514,15 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list empty => false returned', () => { it('Endorsements list empty => false returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: []
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements: []
}
] ]
}; };
@ -518,13 +536,15 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list non-empty, not containing repair waived => false returned', () => { it('Endorsements list non-empty, not containing repair waived => false returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements: [endorsementOptions.EDUCATOR, endorsementOptions.PARKING_GUARD]
}
] ]
}; };
@ -538,17 +558,19 @@ describe('policy-vehicles.vue', () => {
it('Endorsements list contains repair waived => true returned', () => { it('Endorsements list contains repair waived => true returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: [
endorsementOptions.EDUCATOR,
endorsementOptions.REPAIR_WAIVED,
endorsementOptions.PARKING_GUARD
]
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements: [
endorsementOptions.EDUCATOR,
endorsementOptions.REPAIR_WAIVED,
endorsementOptions.PARKING_GUARD
]
}
] ]
}; };
@ -564,6 +586,7 @@ describe('policy-vehicles.vue', () => {
it('policyVehicles is null => empty endorsements array returned', () => { it('policyVehicles is null => empty endorsements array returned', () => {
// Arrange // Arrange
const testValues = { const testValues = {
selectedPolicyVehicle: null,
policyVehicles: null policyVehicles: null
}; };
@ -578,6 +601,7 @@ describe('policy-vehicles.vue', () => {
it('policyVehicles is empty => empty endorsements array returned', () => { it('policyVehicles is empty => empty endorsements array returned', () => {
// Arrange // Arrange
const testValues = { const testValues = {
selectedPolicyVehicle: null,
policyVehicles: [] policyVehicles: []
}; };
@ -595,6 +619,7 @@ describe('policy-vehicles.vue', () => {
const otherVin = getRandomString(17, 17); const otherVin = getRandomString(17, 17);
const testValues = { const testValues = {
selectedVehicleVin: selectedVin, selectedVehicleVin: selectedVin,
selectedPolicyVehicle: null,
policyVehicles: [ policyVehicles: [
{ {
vin: otherVin vin: otherVin
@ -613,13 +638,15 @@ describe('policy-vehicles.vue', () => {
it('vehicle VIN match with endorsements null => empty endorsements array returned', () => { it('vehicle VIN match with endorsements null => empty endorsements array returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: null
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements: null
}
] ]
}; };
@ -634,13 +661,15 @@ describe('policy-vehicles.vue', () => {
it('vehicle VIN match with empty endorsements => empty endorsements array returned', () => { it('vehicle VIN match with empty endorsements => empty endorsements array returned', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const policyVehicle = {
vin,
endorsements: []
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements: []
}
] ]
}; };
@ -656,13 +685,15 @@ describe('policy-vehicles.vue', () => {
// Arrange // Arrange
const vin = getRandomString(17, 17); const vin = getRandomString(17, 17);
const endorsements = [getRandomString(10, 20)]; const endorsements = [getRandomString(10, 20)];
const policyVehicle = {
vin,
endorsements
};
const testValues = { const testValues = {
selectedVehicleVin: vin, selectedVehicleVin: vin,
selectedPolicyVehicle: policyVehicle,
policyVehicles: [ policyVehicles: [
{ policyVehicle
vin,
endorsements
}
] ]
}; };
@ -694,25 +725,4 @@ describe('policy-vehicles.vue', () => {
// Assert // Assert
expect(wrapper.vm.selectedVehicleVin).toBe(vin); 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);
});
}); });

View file

@ -53,8 +53,12 @@ import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js';
import endorsementOptions from '@/constants/endorsement-options.js'; import endorsementOptions from '@/constants/endorsement-options.js';
import globalRules from '@/constants/global-rules.js'; import globalRules from '@/constants/global-rules.js';
import { useMainStore } from '@/store/index.js'; import { useMainStore } from '@/store/index.js';
import bailoutCode from '@/constants/bailoutCode';
import bailoutMessage from '@/constants/bailoutMessage'; import bailoutMessage from '@/constants/bailoutMessage';
import {
deductibleForSelectedVehicle, endorsementsForSelectedVehicle,
noCoverageForSelectedVehicle,
repairWaivedForSelectedVehicle
} from '@/helpers/policy-vehicle-helper';
export default { export default {
name: 'policy-vehicles', name: 'policy-vehicles',
@ -82,6 +86,7 @@ export default {
return { return {
policyVehicles, policyVehicles,
selectedVehicleVin: '', selectedVehicleVin: '',
selectedPolicyVehicle: null,
displayGeneric: true, displayGeneric: true,
policyVinFound: true, policyVinFound: true,
rules: { rules: {
@ -108,33 +113,16 @@ export default {
return mappedData; return mappedData;
}, },
noCoverageForSelectedVehicle() { noCoverageForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) => return noCoverageForSelectedVehicle(this.selectedPolicyVehicle);
policyVehicle.vin === this.selectedVehicleVin);
return (vehicle?.coverages?.length ?? 0) === 0;
}, },
deductibleForSelectedVehicle() { deductibleForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) => return deductibleForSelectedVehicle(this.selectedPolicyVehicle);
policyVehicle?.vin === this.selectedVehicleVin);
if (!vehicle) {
return undefined;
}
return vehicle.coverages?.length ?? false
? vehicle?.coverages[0].deductible
: 0;
}, },
endorsementsForSelectedVehicle() { endorsementsForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) => return endorsementsForSelectedVehicle(this.selectedPolicyVehicle);
policyVehicle?.vin === this.selectedVehicleVin);
if (vehicle?.endorsements?.length > 0) {
return vehicle.endorsements;
}
return [];
}, },
repairWaivedForSelectedVehicle() { repairWaivedForSelectedVehicle() {
const vehicle = this.policyVehicles?.find((policyVehicle) => return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle);
policyVehicle.vin === this.selectedVehicleVin);
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
}, },
selectedVehicle() { selectedVehicle() {
const vehicle = this.mainStore.lookupVehicleByVin(this.selectedVehicleVin); const vehicle = this.mainStore.lookupVehicleByVin(this.selectedVehicleVin);
@ -147,6 +135,7 @@ export default {
// clear previously selected vehicle and image // clear previously selected vehicle and image
this.mainStore.resetVehicleState(); this.mainStore.resetVehicleState();
this.displayGeneric = true; this.displayGeneric = true;
this.selectedPolicyVehicle = null;
} else { } else {
// get vehicle details from selected VIN // get vehicle details from selected VIN
const vehicle = await this.lookupVehicleByVin(value); const vehicle = await this.lookupVehicleByVin(value);
@ -155,12 +144,14 @@ export default {
if (vehicle?.error === true) { if (vehicle?.error === true) {
this.mainStore.resetVehicleState(); this.mainStore.resetVehicleState();
this.displayGeneric = true; this.displayGeneric = true;
this.selectedPolicyVehicle = null;
return; return;
} }
if (vehicle) { if (vehicle) {
// save selected vehicle to the store // save selected vehicle to the store
this.mainStore.updateVehicle(vehicle.data); this.mainStore.updateVehicle(vehicle.data);
this.displayGeneric = false; this.displayGeneric = false;
this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value);
} }
} }
} }

View file

@ -423,7 +423,7 @@ const routingTable = () => [
}, },
{ {
scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_POLICY_VEHICLE, 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, scenario: navigationScenarios.CLICKED_FORWARD_LOADED_DUPLICATE_WITH_NON_POLICY_VEHICLE,

View file

@ -14,6 +14,11 @@ import coverageStatuses from '@/constants/coverage-statuses';
import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants';
import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper'; import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper';
import { paymentMethods } from '@/constants/payment-method-constants'; import { paymentMethods } from '@/constants/payment-method-constants';
import {
deductibleForSelectedVehicle, endorsementsForSelectedVehicle,
noCoverageForSelectedVehicle,
repairWaivedForSelectedVehicle
} from '@/helpers/policy-vehicle-helper';
const storeId = 'main'; const storeId = 'main';
@ -1192,11 +1197,12 @@ export const useMainStore = defineStore({
}); });
}, },
loadSession() { async loadSession() {
const { applicationUser, order, issConfig } = this; const { applicationUser, order, issConfig } = this;
// TODO how to get savedSessionId for a duplicate referral? // 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, method: endpoints.LoadSession.method,
endpoint: endpoints.LoadSession.url, endpoint: endpoints.LoadSession.url,
payload: { payload: {
@ -1206,67 +1212,81 @@ export const useMainStore = defineStore({
parentAccountNumber: issConfig.parentAccountNumber, parentAccountNumber: issConfig.parentAccountNumber,
referralCorrelationId: order.referralCorrelationId referralCorrelationId: order.referralCorrelationId
} }
}).then((response) => { });
const { data } = response; const { data } = response;
if (!data) { if (!data) {
// TODO how should we handle this case? // TODO how should we handle this case?
return resolve(data); return respone;
} }
applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId; applicationUser.crmCustomerId = data.applicationUser?.crmCustomerId;
applicationUser.experiments = data.applicationUser?.experiments ?? []; applicationUser.experiments = data.applicationUser?.experiments ?? [];
applicationUser.savedSessionId = data.applicationUser?.savedSessionId; applicationUser.savedSessionId = data.applicationUser?.savedSessionId;
if (order.policy.policyLookupSuccessful) { if (order.policy.policyLookupSuccessful) {
order.customer.emailAddress = data.customer?.emailAddress; order.customer.emailAddress = data.customer?.emailAddress;
order.customer.firstName = data.customer?.firstName; order.customer.firstName = data.customer?.firstName;
order.customer.lastName = data.customer?.lastName; order.customer.lastName = data.customer?.lastName;
order.customer.phoneNumber = data?.customer?.phoneNumber; order.customer.phoneNumber = data?.customer?.phoneNumber;
order.customer.address.streetAddress = data.customer?.address?.streetAddress; order.customer.address.streetAddress = data.customer?.address?.streetAddress;
order.customer.address.streetAddress2 = data.customer?.address?.streetAddress2; order.customer.address.streetAddress2 = data.customer?.address?.streetAddress2;
order.customer.address.city = data.customer?.address?.city; order.customer.address.city = data.customer?.address?.city;
order.customer.address.state = data.customer?.address?.state; order.customer.address.state = data.customer?.address?.state;
order.customer.address.zipCode = data.customer?.address?.zipCode; order.customer.address.zipCode = data.customer?.address?.zipCode;
order.contactInfo.firstName = data?.customer?.firstName; order.contactInfo.firstName = data?.customer?.firstName;
order.contactInfo.lastName = data?.customer?.lastName; order.contactInfo.lastName = data?.customer?.lastName;
order.contactInfo.emailAddress = data?.customer?.emailAddress; order.contactInfo.emailAddress = data?.customer?.emailAddress;
order.contactInfo.phoneNumber = data?.customer?.phoneNumber; order.contactInfo.phoneNumber = data?.customer?.phoneNumber;
order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn; order.contactInfo.requestTextUpdates = data?.customer?.isSmsOptIn;
order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified; order.payment.insuranceCoverage.isVerified = data?.payment?.insuranceCoverage?.isVerified;
order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus; order.payment.insuranceCoverage.coverageStatus = data?.payment?.insuranceCoverage?.coverageStatus;
order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber; order.payment.insuranceCoverage.claimNumber = data?.payment?.insuranceCoverage?.claimNumber;
if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) { if (order.policy.vehicles.length !== 0 && data.vehicle?.carId) {
order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber; order.vehicle.registration.licensePlate = data?.vehicle?.licensePlateNumber;
if (data.vehicle.vin) { if (data.vehicle.vin) {
const vehicle = order.policy.vehicles.find((v) => v.vin === data.vehicle.vin); const vehicle = order.policy.vehicles.find((v) => v.vin === data.vehicle.vin);
if (vehicle) { if (vehicle) {
order.vehicle.vin = data.vehicle.vin; 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.vehicle.year = data.vehicle.year;
order.referralDate = data?.referralDate; order.vehicle.make = data.vehicle.make;
order.referralCorrelationId = data?.referralCorrelationId; order.vehicle.model = data.vehicle.model;
order.referralSequenceNumber = data?.referralSequenceNumber; order.vehicle.style = data.vehicle.style;
order.eon = data?.eon; }
order.loadedFromDupeCheck = true; }
order.loadedSessionClearedPreviousData = false;
return resolve(data); order.referralNumber = data?.referralNumber;
}, (error) => { order.referralDate = data?.referralDate;
reject(error); 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) { setSaveSessionPromise(promise) {
@ -1425,7 +1445,7 @@ export const useMainStore = defineStore({
// These could be undefined // These could be undefined
this.order.policy.noCoverage = vehicle.noCoverage; 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 this.order.payment.insuranceCoverage.coverageStatus = vehicle.noCoverage
? coverageStatuses.NO_COMP ? coverageStatuses.NO_COMP
: coverageStatuses.PENDING; : coverageStatuses.PENDING;