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: { methods: {
async updateShops() { async updateShops(autoExpand = false) {
this.errorMessage = ''; 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) { if (result.length === 0) {
this.errorMessage = errorMessages.ZIP_CODE_NOT_SERVICED_FOR_VEHICLE; this.errorMessage = errorMessages.ZIP_CODE_NOT_SERVICED_FOR_VEHICLE;
} }
else { else {
this.nearbyShops = await this.getNearbyShops(this.searchRadiusInMiles); this.nearbyShops = result;
this.searchRadiusInMiles = this.searchRadiusArray[currentSearchIndex].Name;
} }
}, },
openModal() { openModal() {
@ -256,7 +263,8 @@ export default {
onModalOpened() { onModalOpened() {
this.internalZipcode = this.serviceZipcode; this.internalZipcode = this.serviceZipcode;
this.searchRadiusInMiles = "25"; this.searchRadiusInMiles = "25";
this.updateShops().then(() => { this.nearbyShops = [];
this.updateShops(true).then(() => {
this.internalProviderNumber = this.nearbyShops[0]?.providerNumber; this.internalProviderNumber = this.nearbyShops[0]?.providerNumber;
}); });
this.forceServiceZipRerender(); this.forceServiceZipRerender();
@ -308,7 +316,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.renderServiceZip = true; this.renderServiceZip = true;
}); });
} },
} }
}; };
</script> </script>