SSR-1830 Fix Policy Vehicle race condition
This commit is contained in:
parent
23d7f736b5
commit
96693dbecc
1 changed files with 7 additions and 4 deletions
|
|
@ -85,7 +85,6 @@ export default {
|
||||||
return {
|
return {
|
||||||
policyVehicles,
|
policyVehicles,
|
||||||
selectedVehicleVin: '',
|
selectedVehicleVin: '',
|
||||||
selectedPolicyVehicle: null,
|
|
||||||
displayGeneric: true,
|
displayGeneric: true,
|
||||||
policyVinFound: true,
|
policyVinFound: true,
|
||||||
rules: {
|
rules: {
|
||||||
|
|
@ -112,6 +111,13 @@ export default {
|
||||||
}) ?? [];
|
}) ?? [];
|
||||||
return mappedData;
|
return mappedData;
|
||||||
},
|
},
|
||||||
|
selectedPolicyVehicle() {
|
||||||
|
if (this.selectedVehicleVin !== vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
|
||||||
|
return this.policyVehicles.find((p) => p.vin === this.selectedVehicleVin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
noCoverageForSelectedVehicle() {
|
noCoverageForSelectedVehicle() {
|
||||||
return noCoverageForSelectedVehicle(this.selectedPolicyVehicle);
|
return noCoverageForSelectedVehicle(this.selectedPolicyVehicle);
|
||||||
},
|
},
|
||||||
|
|
@ -135,7 +141,6 @@ 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);
|
||||||
|
|
@ -144,13 +149,11 @@ 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.displayGeneric = false;
|
this.displayGeneric = false;
|
||||||
this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value);
|
|
||||||
useMainStore().updateVehicle({
|
useMainStore().updateVehicle({
|
||||||
...vehicle.data,
|
...vehicle.data,
|
||||||
policyVehicleId: this.selectedPolicyVehicle?.id,
|
policyVehicleId: this.selectedPolicyVehicle?.id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue