Some formatting and removed answers = [] references

This commit is contained in:
Scott Kiener 2025-07-17 10:04:42 -04:00
parent fa0d988335
commit 46c2119426

View file

@ -154,19 +154,16 @@ export default {
};
},
displaySeeMoreLocationsLink() {
if (!this.shopProviders.length)
return false;
if (!this.shopProviders.length) return false;
return this.numberOfShopsToDisplay < this.shopProviders.length;
},
},
methods: {
openModal() {
// Reset local state from parent
this.localShopProviderData = this.shopProviderDataFromParent;
this.localZipCode = this.zipCodeFromParent;
this.answers = [];
// This will be set once the modal is open (updateSelectedAnswer()) to ensure that the
// This will be set once the modal is open (updateSelectedAnswer()) to ensure that the
// correct answer is selected
this.localSelectedProviderNumber = null;
@ -175,14 +172,14 @@ export default {
);
if (selectedProviderNumberFromParentIndex > -1) {
this.numberOfShopsToDisplay = Math.ceil((selectedProviderNumberFromParentIndex + 1) / 3) * 3;
this.numberOfShopsToDisplay =
Math.ceil((selectedProviderNumberFromParentIndex + 1) / 3) * 3;
} else {
this.numberOfShopsToDisplay = 3;
}
this.updateShopsForZip(this.localZipCode);
this.updateShopsForZip();
this.$refs.shopQuestionModal.openModal();
},
updateSelectedAnswer() {
this.localSelectedProviderNumber = this.selectedProviderNumberFromParent;
@ -193,34 +190,40 @@ export default {
});
},
isModalFooterButtonDisabled() {
return this.displayInvalidZipAlert || this.displayNoShopsAlert || !this.localSelectedProviderNumber;
return (
this.displayInvalidZipAlert ||
this.displayNoShopsAlert ||
!this.localSelectedProviderNumber
);
},
updateShopListWithNextShops(numberToGet = 3) {
//gaAction = this.GaActions.SHOPS_FIRST_DISPLAYED; --This needs to actually fire on initial display, can never happen here
this.updateShopAnswersFromProviderList({extraShopsToDisplay:3});
this.updateShopAnswersFromProviderList({ extraShopsToDisplay: 3 });
this.pushShopsDisplayedGAEvent(this.answers);
},
updateShopAnswersFromProviderList({extraShopsToDisplay}) {
updateShopAnswersFromProviderList({ extraShopsToDisplay }) {
const indexOfLastShopToReturn = this.numberOfShopsToDisplay + extraShopsToDisplay;
const updatedProvidersToDisplay = this.shopProviders.slice(0, indexOfLastShopToReturn);
this.numberOfShopsToDisplay = updatedProvidersToDisplay.length;
const shopAnswersToDisplayFromProviderList = updatedProvidersToDisplay.map((shopProvider) => {
const streetAddress = this.toTitleCase(shopProvider.address.streetAddress);
const city = this.toTitleCase(shopProvider.address.city);
const state = shopProvider.address.state;
const zipCode = shopProvider.address.zipCode;
const distanceInMiles = Math.round(shopProvider.distanceInMiles * 2) / 2;
const shopAnswersToDisplayFromProviderList = updatedProvidersToDisplay.map(
(shopProvider) => {
const streetAddress = this.toTitleCase(shopProvider.address.streetAddress);
const city = this.toTitleCase(shopProvider.address.city);
const state = shopProvider.address.state;
const zipCode = shopProvider.address.zipCode;
const distanceInMiles = Math.round(shopProvider.distanceInMiles * 2) / 2;
return {
buttonLabel: city,
buttonLabelSubCopy: `${distanceInMiles} mi`,
buttonBodyCopy: `${streetAddress}, ${city}, ${state} ${zipCode}`,
additionalButtonData: this.additionalButtonData,
value: shopProvider.providerNumber,
};
});
return {
buttonLabel: city,
buttonLabelSubCopy: `${distanceInMiles} mi`,
buttonBodyCopy: `${streetAddress}, ${city}, ${state} ${zipCode}`,
additionalButtonData: this.additionalButtonData,
value: shopProvider.providerNumber,
};
}
);
this.answers = shopAnswersToDisplayFromProviderList;
},
@ -238,7 +241,12 @@ export default {
joinedShops = "no-shops";
}
this.pushEventToGA(this.GaCategories.SERVICE_LOCATION, this.GaActions.MORE_LOCATIONS_CLICKED, joinedShops, true);
this.pushEventToGA(
this.GaCategories.SERVICE_LOCATION,
this.GaActions.MORE_LOCATIONS_CLICKED,
joinedShops,
true
);
},
closeModal() {
this.modal.closeModal();
@ -249,10 +257,7 @@ export default {
async onSearchZip(event) {
event.preventDefault();
this.resetAlerts();
const zipCodeData = await this.getZipCodeData(
this.localZipCode,
"service-location"
);
const zipCodeData = await this.getZipCodeData(this.localZipCode, "service-location");
if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true;
@ -276,25 +281,23 @@ export default {
this.displayNoShopsAlert = false;
this.localShopProviderData = result.data;
this.numberOfShopsToDisplay = 3;
this.updateShopsForZip(this.localZipCode);
this.updateShopsForZip();
});
}
}
},
updateShopsForZip(zipCode) {
if (!zipCode) {
this.answers = [];
return;
}
updateShopsForZip() {
this.updateShopAnswersFromProviderList({ extraShopsToDisplay: 0 });
if (!this.shopProviders.length) {
this.answers = [];
this.displayNoShopsAlert = true;
this.displaySeeMoreLocationsLink = false;
return;
}
this.updateShopAnswersFromProviderList({extraShopsToDisplay:0})
if (!this.answers.some((a) => String(a.value) === String(this.localSelectedProviderNumber))) {
if (
!this.answers.some(
(a) => String(a.value) === String(this.localSelectedProviderNumber)
)
) {
this.localSelectedProviderNumber = null;
}
// I think we should call our new pushGA Event here with new mapped data