Minor adjustments

This commit is contained in:
brydon1 2023-06-21 17:14:33 -04:00
parent 577cc05695
commit 0b4d626d90
2 changed files with 20 additions and 23 deletions

View file

@ -50,9 +50,11 @@ export default {
name: "policy-vehicles",
mixins: [BaseFormMixin],
data() {
return {
selectedVehicleVin: "",
bailout: false
const policyVehicles = useMainStore().pageData(issPageValues.POLICY_VEHICLES);
return {
policyVehicles: policyVehicles,
selectedVehicleVin: policyVehicles.length == 0 ? "" : policyVehicles[0].vin,
bailout: false
}
},
async beforeRouteEnter(to, from, next)
@ -64,13 +66,14 @@ export default {
{
resultKey: "cmsContent",
promise: cmsContentPromise,
},];
//use resultMap to populate layout content.
let resultMap = await settleAllPromises(promiseResultMap);
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
});
},
},
];
//use resultMap to populate layout content.
let resultMap = await settleAllPromises(promiseResultMap);
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
});
},
methods:
{
backButtonAction() {
@ -95,6 +98,7 @@ export default {
// If they go backwards select vehicle => forward => one deductible => back to vehicle selection => forward again => right info
// backwards => vehicle unverified => clear coverage info
// keep this in mind
console.log("Going to update vehicle");
this.mainStore.updateVehicle(this.vehicleFromLookup);
}
return this.navigateForward();
@ -139,7 +143,7 @@ export default {
computed:{
VehiclesForQuestions() {
// Map API result data, to address-vehicles data structure
const vehicles = this.VehiclesFromApi;
const vehicles = this.policyVehicles;
const mappedData = vehicles.map((v) => {
const maskSymbol = "X";
const vinStart = maskSymbol.repeat(v.vin.length - 6);
@ -154,21 +158,18 @@ export default {
});
return mappedData;
},
VehiclesFromApi() {
return useMainStore().pageData(issPageValues.POLICY_VEHICLES);
},
noCoverageForSelectedVehicle() {
const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
return vehicle.coverages.length == 0;
},
deductibleForSelectedVehicle() {
const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
return vehicle?.coverages?.length == 0 ?? true
? 0
: vehicle.coverages[0].deductible;
},
repairWaivedForSelectedVehicle() {
const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; });
return vehicle.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
}
},

View file

@ -52,7 +52,6 @@ const getDefaultState = () => {
isDamageGlassOnly: null,
noCoverage: null,
deductible: {
// if repair waived, then 0, otherwise same as other
repair: null, // numerical value; how much customer owes on deductible in repair case
replace: null // numerical value; how much customer owes on deductible in replace case,
},
@ -750,11 +749,9 @@ export const useMainStore = defineStore({
this.order.lineItems.vaps = partsData;
},
// TODO Where all will this be called and could it be an issue?
updateVehicle(vehicle) {
// Assuming that the method caller pass all the properties.
// otherwise need to check for undefined for every property.
this.order.vehicle.carId = vehicle.carId;
this.order.vehicle.category = vehicle.category;
this.order.vehicle.year = vehicle.year;
@ -766,11 +763,10 @@ export const useMainStore = defineStore({
this.order.vehicle.imageVifNumber = vehicle.imageVifNumber;
this.order.vehicle.imageColor = vehicle.imageVifColor;
// These could be undefined
this.order.policy.noCoverage = vehicle.noCoverage;
this.order.policy.deductible.replace = vehicle.deductible;
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false
? 0
: vehicle.deductible;
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible;
this.resetSupportingItemsState();
this.resetVapsState();