Some formatting and removed answers = [] references
This commit is contained in:
parent
fa0d988335
commit
46c2119426
1 changed files with 43 additions and 40 deletions
|
|
@ -154,18 +154,15 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
displaySeeMoreLocationsLink() {
|
displaySeeMoreLocationsLink() {
|
||||||
if (!this.shopProviders.length)
|
if (!this.shopProviders.length) return false;
|
||||||
return false;
|
|
||||||
return this.numberOfShopsToDisplay < this.shopProviders.length;
|
return this.numberOfShopsToDisplay < this.shopProviders.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openModal() {
|
openModal() {
|
||||||
// Reset local state from parent
|
// Reset local state from parent
|
||||||
this.localShopProviderData = this.shopProviderDataFromParent;
|
this.localShopProviderData = this.shopProviderDataFromParent;
|
||||||
this.localZipCode = this.zipCodeFromParent;
|
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
|
// correct answer is selected
|
||||||
this.localSelectedProviderNumber = null;
|
this.localSelectedProviderNumber = null;
|
||||||
|
|
@ -175,14 +172,14 @@ export default {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selectedProviderNumberFromParentIndex > -1) {
|
if (selectedProviderNumberFromParentIndex > -1) {
|
||||||
this.numberOfShopsToDisplay = Math.ceil((selectedProviderNumberFromParentIndex + 1) / 3) * 3;
|
this.numberOfShopsToDisplay =
|
||||||
|
Math.ceil((selectedProviderNumberFromParentIndex + 1) / 3) * 3;
|
||||||
} else {
|
} else {
|
||||||
this.numberOfShopsToDisplay = 3;
|
this.numberOfShopsToDisplay = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateShopsForZip(this.localZipCode);
|
this.updateShopsForZip();
|
||||||
this.$refs.shopQuestionModal.openModal();
|
this.$refs.shopQuestionModal.openModal();
|
||||||
|
|
||||||
},
|
},
|
||||||
updateSelectedAnswer() {
|
updateSelectedAnswer() {
|
||||||
this.localSelectedProviderNumber = this.selectedProviderNumberFromParent;
|
this.localSelectedProviderNumber = this.selectedProviderNumberFromParent;
|
||||||
|
|
@ -193,20 +190,25 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isModalFooterButtonDisabled() {
|
isModalFooterButtonDisabled() {
|
||||||
return this.displayInvalidZipAlert || this.displayNoShopsAlert || !this.localSelectedProviderNumber;
|
return (
|
||||||
|
this.displayInvalidZipAlert ||
|
||||||
|
this.displayNoShopsAlert ||
|
||||||
|
!this.localSelectedProviderNumber
|
||||||
|
);
|
||||||
},
|
},
|
||||||
updateShopListWithNextShops(numberToGet = 3) {
|
updateShopListWithNextShops(numberToGet = 3) {
|
||||||
//gaAction = this.GaActions.SHOPS_FIRST_DISPLAYED; --This needs to actually fire on initial display, can never happen here
|
//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);
|
this.pushShopsDisplayedGAEvent(this.answers);
|
||||||
},
|
},
|
||||||
updateShopAnswersFromProviderList({extraShopsToDisplay}) {
|
updateShopAnswersFromProviderList({ extraShopsToDisplay }) {
|
||||||
const indexOfLastShopToReturn = this.numberOfShopsToDisplay + extraShopsToDisplay;
|
const indexOfLastShopToReturn = this.numberOfShopsToDisplay + extraShopsToDisplay;
|
||||||
const updatedProvidersToDisplay = this.shopProviders.slice(0, indexOfLastShopToReturn);
|
const updatedProvidersToDisplay = this.shopProviders.slice(0, indexOfLastShopToReturn);
|
||||||
this.numberOfShopsToDisplay = updatedProvidersToDisplay.length;
|
this.numberOfShopsToDisplay = updatedProvidersToDisplay.length;
|
||||||
|
|
||||||
const shopAnswersToDisplayFromProviderList = updatedProvidersToDisplay.map((shopProvider) => {
|
const shopAnswersToDisplayFromProviderList = updatedProvidersToDisplay.map(
|
||||||
|
(shopProvider) => {
|
||||||
const streetAddress = this.toTitleCase(shopProvider.address.streetAddress);
|
const streetAddress = this.toTitleCase(shopProvider.address.streetAddress);
|
||||||
const city = this.toTitleCase(shopProvider.address.city);
|
const city = this.toTitleCase(shopProvider.address.city);
|
||||||
const state = shopProvider.address.state;
|
const state = shopProvider.address.state;
|
||||||
|
|
@ -220,7 +222,8 @@ export default {
|
||||||
additionalButtonData: this.additionalButtonData,
|
additionalButtonData: this.additionalButtonData,
|
||||||
value: shopProvider.providerNumber,
|
value: shopProvider.providerNumber,
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.answers = shopAnswersToDisplayFromProviderList;
|
this.answers = shopAnswersToDisplayFromProviderList;
|
||||||
},
|
},
|
||||||
|
|
@ -238,7 +241,12 @@ export default {
|
||||||
joinedShops = "no-shops";
|
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() {
|
closeModal() {
|
||||||
this.modal.closeModal();
|
this.modal.closeModal();
|
||||||
|
|
@ -249,10 +257,7 @@ export default {
|
||||||
async onSearchZip(event) {
|
async onSearchZip(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.resetAlerts();
|
this.resetAlerts();
|
||||||
const zipCodeData = await this.getZipCodeData(
|
const zipCodeData = await this.getZipCodeData(this.localZipCode, "service-location");
|
||||||
this.localZipCode,
|
|
||||||
"service-location"
|
|
||||||
);
|
|
||||||
if (!zipCodeData.isValid) {
|
if (!zipCodeData.isValid) {
|
||||||
this.displayInvalidZipAlert = true;
|
this.displayInvalidZipAlert = true;
|
||||||
|
|
||||||
|
|
@ -276,25 +281,23 @@ export default {
|
||||||
this.displayNoShopsAlert = false;
|
this.displayNoShopsAlert = false;
|
||||||
this.localShopProviderData = result.data;
|
this.localShopProviderData = result.data;
|
||||||
this.numberOfShopsToDisplay = 3;
|
this.numberOfShopsToDisplay = 3;
|
||||||
this.updateShopsForZip(this.localZipCode);
|
this.updateShopsForZip();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateShopsForZip(zipCode) {
|
updateShopsForZip() {
|
||||||
if (!zipCode) {
|
this.updateShopAnswersFromProviderList({ extraShopsToDisplay: 0 });
|
||||||
this.answers = [];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!this.shopProviders.length) {
|
if (!this.shopProviders.length) {
|
||||||
this.answers = [];
|
|
||||||
this.displayNoShopsAlert = true;
|
this.displayNoShopsAlert = true;
|
||||||
this.displaySeeMoreLocationsLink = false;
|
this.displaySeeMoreLocationsLink = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
this.updateShopAnswersFromProviderList({extraShopsToDisplay:0})
|
!this.answers.some(
|
||||||
if (!this.answers.some((a) => String(a.value) === String(this.localSelectedProviderNumber))) {
|
(a) => String(a.value) === String(this.localSelectedProviderNumber)
|
||||||
|
)
|
||||||
|
) {
|
||||||
this.localSelectedProviderNumber = null;
|
this.localSelectedProviderNumber = null;
|
||||||
}
|
}
|
||||||
// I think we should call our new pushGA Event here with new mapped data
|
// I think we should call our new pushGA Event here with new mapped data
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue