Auto expand shop search until shop is found

This commit is contained in:
Alex Humphries 2026-01-15 14:51:50 -05:00
parent d85c0f6c38
commit b1ec2a298d

View file

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