From b1ec2a298d3f0ff03b6d416410bfc86bb320beb2 Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Thu, 15 Jan 2026 14:51:50 -0500 Subject: [PATCH] Auto expand shop search until shop is found --- .../shop-address/shop-address.vue | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/layouts/service-location/shop-address/shop-address.vue b/src/layouts/service-location/shop-address/shop-address.vue index 2417a52a..88fb545d 100644 --- a/src/layouts/service-location/shop-address/shop-address.vue +++ b/src/layouts/service-location/shop-address/shop-address.vue @@ -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; }); - } + }, } };