Merge pull request #899 from Safelite/feature/digital/SSR-1830

SSR-1830 Fix Policy Vehicle race condition
This commit is contained in:
Josh Dassinger 2024-11-19 15:37:40 -06:00 committed by GitHub
commit ae94b67700
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,7 +85,6 @@ export default {
return {
policyVehicles,
selectedVehicleVin: '',
selectedPolicyVehicle: null,
displayGeneric: true,
policyVinFound: true,
rules: {
@ -112,6 +111,13 @@ export default {
}) ?? [];
return mappedData;
},
selectedPolicyVehicle() {
if (this.selectedVehicleVin !== vehicleSelectionOptions.VEHICLE_NOT_LISTED) {
return this.policyVehicles.find((p) => p.vin === this.selectedVehicleVin);
}
return null;
},
noCoverageForSelectedVehicle() {
return noCoverageForSelectedVehicle(this.selectedPolicyVehicle);
},
@ -135,7 +141,6 @@ 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);
@ -144,13 +149,11 @@ 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.displayGeneric = false;
this.selectedPolicyVehicle = this.policyVehicles.find((p) => p.vin === value);
useMainStore().updateVehicle({
...vehicle.data,
policyVehicleId: this.selectedPolicyVehicle?.id,