CASH-1339 | Add big truck alert to shop-question-popup

This commit is contained in:
Scott Kiener 2025-08-15 11:03:14 -04:00
parent 2fa8b98e4f
commit f5f57e364c

View file

@ -48,7 +48,13 @@
cmsWidgetName="AlertNoShopsWidget" cmsWidgetName="AlertNoShopsWidget"
v-if="displayNoShopsAlert" v-if="displayNoShopsAlert"
alertClass="alert-warning" /> alertClass="alert-warning" />
<div v-if="!displayInvalidZipAlert"> <alert
ref="alertNoShops"
class="my-5"
cmsWidgetName="AlertNoServiceWidget"
v-if="displayNoServiceAlert"
alertClass="alert-danger" />
<div v-if="displayShopsList">
<buttonQuestion <buttonQuestion
ref="buttonQuestion" ref="buttonQuestion"
buttonTypeString="shopListButton" buttonTypeString="shopListButton"
@ -116,6 +122,7 @@ export default {
localSelectedProviderNumber: null, localSelectedProviderNumber: null,
zipCodeData: null, zipCodeData: null,
isLoading: false, isLoading: false,
displayNoServiceAlert: false,
}; };
}, },
props: { props: {
@ -148,6 +155,9 @@ export default {
displayNoShopsAlert() { displayNoShopsAlert() {
return !this.shopProviders.length && !this.displayInvalidZipAlert; return !this.shopProviders.length && !this.displayInvalidZipAlert;
}, },
displayShopsList() {
return !this.displayInvalidZipAlert && !this.displayNoServiceAlert;
},
modal() { modal() {
return this.$refs.shopQuestionModal; return this.$refs.shopQuestionModal;
}, },
@ -170,6 +180,7 @@ export default {
this.isLoading || this.isLoading ||
this.displayInvalidZipAlert || this.displayInvalidZipAlert ||
this.displayNoShopsAlert || this.displayNoShopsAlert ||
this.displayNoServiceAlert ||
!this.localSelectedProviderNumber !this.localSelectedProviderNumber
); );
}, },
@ -199,6 +210,7 @@ export default {
openModal() { openModal() {
// Reset local state from parent // Reset local state from parent
this.zipCodeData = null; this.zipCodeData = null;
this.displayNoServiceAlert = false;
this.localShopProviderData = this.shopProviderDataFromParent; this.localShopProviderData = this.shopProviderDataFromParent;
this.localZipCode = this.zipCodeFromParent; this.localZipCode = this.zipCodeFromParent;
// 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
@ -258,6 +270,7 @@ export default {
}, },
async onSearchZip(event) { async onSearchZip(event) {
event.preventDefault(); event.preventDefault();
this.displayNoServiceAlert = false;
if (!this.localZipCode) { if (!this.localZipCode) {
this.zipCodeData = { this.zipCodeData = {
isValid: false, isValid: false,
@ -265,23 +278,24 @@ export default {
return; return;
} }
this.isLoading = true; this.isLoading = true;
this.zipCodeData = await this.getZipCodeData(this.localZipCode, "service-location"); this.zipCodeData = await this.getZipCodeData(this.localZipCode, "service-location");
// Add zipCode to zipCodeData as it does not come back from endpoint // Add zipCode to zipCodeData as it does not come back from endpoint
this.zipCodeData.zipCode = this.localZipCode; this.zipCodeData.zipCode = this.localZipCode;
if (this.zipCodeData.isValid) { if (this.zipCodeData.isValid) {
if (this.isVehicleHeavyTruck) { if (this.$store.getters.order.vehicle?.isBigTruck) {
// check the location endpoint to verify this zip can service a heavy truck // check the location endpoint to verify this zip can service a heavy truck
const closestShops = await getClosestApplicableShops( const closestShops = await getClosestApplicableShops(
this.localZipCode, this.localZipCode,
this.carId, this.$store.getters.order.vehicle.carId,
"service-location" "service-location"
); );
if (!closestShops || closestShops.providers?.length === 0) { if (!closestShops || closestShops.providers?.length === 0) {
// We need an alert for heavy trucks this.isLoading = false;
this.displayNoServiceAlert = true;
return null; return null;
} }
} else {
getShopProviderData(this.localZipCode).then(async (result) => { getShopProviderData(this.localZipCode).then(async (result) => {
this.localShopProviderData = result.data; this.localShopProviderData = result.data;
this.numberOfShopsToDisplay = 3; this.numberOfShopsToDisplay = 3;