Auto expand shop search until shop is found
This commit is contained in:
parent
d85c0f6c38
commit
b1ec2a298d
1 changed files with 13 additions and 5 deletions
|
|
@ -237,14 +237,21 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
async updateShops() {
|
||||
async updateShops(autoExpand = false) {
|
||||
this.errorMessage = '';
|
||||
const result = await this.getNearbyShops(this.searchRadiusInMiles);
|
||||
let result = await this.getNearbyShops(this.searchRadiusInMiles);
|
||||
let currentSearchIndex = this.searchRadiusArray.findIndex(option => option.Name === this.searchRadiusInMiles);
|
||||
while (autoExpand && result.length === 0 && currentSearchIndex < this.searchRadiusArray.length - 1) {
|
||||
const newSearchRadius = this.searchRadiusArray[currentSearchIndex + 1].Name;
|
||||
result = await this.getNearbyShops(newSearchRadius);
|
||||
currentSearchIndex++;
|
||||
}
|
||||
if (result.length === 0) {
|
||||
this.errorMessage = errorMessages.ZIP_CODE_NOT_SERVICED_FOR_VEHICLE;
|
||||
}
|
||||
else {
|
||||
this.nearbyShops = await this.getNearbyShops(this.searchRadiusInMiles);
|
||||
this.nearbyShops = result;
|
||||
this.searchRadiusInMiles = this.searchRadiusArray[currentSearchIndex].Name;
|
||||
}
|
||||
},
|
||||
openModal() {
|
||||
|
|
@ -256,7 +263,8 @@ export default {
|
|||
onModalOpened() {
|
||||
this.internalZipcode = this.serviceZipcode;
|
||||
this.searchRadiusInMiles = "25";
|
||||
this.updateShops().then(() => {
|
||||
this.nearbyShops = [];
|
||||
this.updateShops(true).then(() => {
|
||||
this.internalProviderNumber = this.nearbyShops[0]?.providerNumber;
|
||||
});
|
||||
this.forceServiceZipRerender();
|
||||
|
|
@ -308,7 +316,7 @@ export default {
|
|||
this.$nextTick(() => {
|
||||
this.renderServiceZip = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue