diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index 7a9ac00d0..106ed892c 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -149,6 +149,23 @@ export async function getAvailabilityRating( return shopStatus; } +export async function getClosestApplicableShops(serviceZipCode, carId, pageNameToLog) { + if (!serviceZipCode) { + return null; + } + + const closestShops = await baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.GET_CLOSEST_APPLICABLE_SHOPS, + { + zip: serviceZipCode, + carId: carId, + }, + pageNameToLog + ); + + return closestShops.data; +} + export async function getZipCodeData(serviceZipCode) { return await baseMixin.methods.getZipCodeData(serviceZipCode, "service-location"); } diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 56c76bb2d..142c3468b 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -15,6 +15,8 @@ editScreenReaderTextCmsWidgetName="ScreenReaderZipEditWidget" v-model="serviceZipCodeQuestion" ref="serviceZipCodeQuestion" + :carId="carId" + :isVehicleHeavyTruck="isVehicleHeavyTruck" :mobileFeePart="mobileFeePart" @updated-mobile-fee-part="setMobileFeePart" @updated-recycle-fee-part="setRecycleFeePart" @@ -186,9 +188,11 @@ export default { return { streetAddress: this.getServiceAddressFromStore(), apartmentNumberOrBusinessName: this.getServiceAddress2FromStore(), + carId: this.getCarIdfromStore(), city: this.getServiceCityFromStore(), state: this.getServiceStateFromStore(), zipCode: this.getServiceZipCodeFromStore(), + isVehicleHeavyTruck: this.getIsVehicleHeavyTruckFromStore(), isVehicleProtected: this.getIsVehicleProtectedFromStore(), isGlassServiceableInshop: null, isRecalibrationServiceableInshop: null, @@ -514,6 +518,9 @@ export default { }); } }, + getCarIdfromStore() { + return store.getters.vehicle.carId; + }, getServiceAddressFromStore() { return store.getters.order.serviceLocation.address; }, @@ -529,6 +536,9 @@ export default { getServiceZipCodeFromStore() { return store.getters.order.serviceLocation.zipCode; }, + getIsVehicleHeavyTruckFromStore() { + return store.getters.isHeavyTruckVehicle; + }, getIsVehicleProtectedFromStore() { return store.getters.order.serviceLocation.isVehicleProtected; }, diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index a2ab4134e..5e7aa73e4 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -33,6 +33,13 @@ cmsWidgetName="AlertInvalidZipWidget" alertClass="alert-danger" v-bind:isDismissible="false" /> + @@ -48,6 +55,7 @@ import { getPricedRecycleFeePart, getServiceabilityDetails, getBillToAccountNumber, + getClosestApplicableShops, } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; export default { @@ -63,6 +71,7 @@ export default { internalModel: this.copyModel(this.modelValue), serviceZipCodeTextInputId: "", displayInvalidZipAlert: false, + displayNoServiceAlert: false, }; }, props: { @@ -73,6 +82,11 @@ export default { zipCode: "", }), }, + carId: String, + isVehicleHeavyTruck: { + type: Boolean, + default: false, + }, mobileFeePart: { type: Object, default: () => ({}), @@ -107,6 +121,7 @@ export default { methods: { resetAlerts() { this.displayInvalidZipAlert = false; + this.displayNoServiceAlert = false; }, resetsOnZipInput() { this.resetAlerts(); @@ -155,6 +170,22 @@ export default { this.focusOnZipInput(); this.resetModalButtonStyle(); } else { + if (this.isVehicleHeavyTruck) { + // check the location endpoint to verify this zip can service a heavy truck + const closestShops = await getClosestApplicableShops( + this.internalModel.zipCode, + this.carId, + "service-location" + ); + + if (!closestShops || closestShops.providers?.length === 0) { + this.displayNoServiceAlert = true; + this.focusOnZipInput(); + this.resetModalButtonStyle(); + return null; + } + } + this.internalModel.state = zipCodeData.state; this.internalModel.zipCodeCtu = zipCodeData.zipCodeCtu;