diff --git a/src/digital-components/textbox-question/textbox-question.vue b/src/digital-components/textbox-question/textbox-question.vue index 7df4436f1..23ff83d0b 100644 --- a/src/digital-components/textbox-question/textbox-question.vue +++ b/src/digital-components/textbox-question/textbox-question.vue @@ -182,11 +182,11 @@ export default { }; }, methods: { - focusSearchInput() { + focusSearchInput(event) { // Focus cursor in input when search icon is clicked const field = document.querySelector("input"); field.focus(); - this.$emit("search-icon-click"); + this.$emit("search-icon-click", event); }, async imageChanged(e) { let file = e.target.files[0]; diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 56c18da12..5d07867ec 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -105,23 +105,11 @@ class="ps-4 pe-4 mt-4" /> @@ -174,7 +162,6 @@ import shopQuestion from "@/layouts/service-location/shop-question/shop-question import shopQuestionPopup from "@/layouts/service-location/shop-question/shop-question-popup"; import buttonQuestion from "@/digital-components/button-question/button-question.vue"; import shopListButton from "@/layouts/service-location/shop-question/shop-list-button/shop-list-button"; -import { getAvailabilityRating } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import navbar from "@/fmg-components/nav-bar/nav-bar"; @@ -813,17 +800,7 @@ export default { return this.displayNoShopsAlert || !this.isMobileAddressValid; }, additionalButtonData() { - const startDate = new Date(); - const endDate = new Date(); - endDate.setDate(startDate.getDate() + 6); - - const formattedStartDate = startDate.toISOString().split("T")[0]; - const formattedEndDate = endDate.toISOString().split("T")[0]; - return { - availabilityRatingCallback: getAvailabilityRating, - startDate: formattedStartDate, - endDate: formattedEndDate, shopAppointmentType: this.appointmentType, }; }, @@ -1168,43 +1145,20 @@ export default { startTime: "08:00", }; }, - onShopSelected(providerObject) { - const current = this.shopProviderData?.shopProviders?.find( - (p) => p.providerNumber === this.selectedProvider?.providerNumber - ); - if (current) { - this.selectedProvider = current; - } + onShopSelected(shopQuestionPopUpData) { + this.shopProviderData = shopQuestionPopUpData.shopProviderData; + this.setServiceabilityDetails(shopQuestionPopUpData.serviceabilityDetails); + this.selectedProvider = this.shopProviderData.shopProviders.find((shopProvider) => { + return shopProvider.providerNumber === shopQuestionPopUpData.selectedProviderNumber; + }); - let provider = this.shopProviderData?.shopProviders?.find( - (p) => p.providerNumber === providerObject?.providerNumber - ); - this.selectedProvider = provider; - if (providerObject && providerObject.address) { - this.zipCode = providerObject.searchedZip; - this.state = providerObject.searchedState; - } - }, - setZipcodeCtu(zipcodeCtu) { - this.zipCodeCtu = zipcodeCtu; - }, - onShopModelUpdated(newModel) { - if (newModel.zipCode) { - this.zipCode = newModel.zipCode; - } - if (newModel.zipCodeCtu) { - this.zipCodeCtu = newModel.zipCodeCtu; - } - if (newModel.state) { - this.state = newModel.state; - } - if (this.shopProviderData && newModel.selectedProviderNumber) { - const provider = this.shopProviderData.shopProviders.find( - (p) => p.providerNumber === newModel.selectedProviderNumber - ); - if (provider) { - this.selectedProvider = provider; - } + // No zipCodeData comes back if zip was not changed + if (shopQuestionPopUpData.zipCodeData) { + this.zipCode = shopQuestionPopUpData.zipCodeData.zipCode; + this.state = shopQuestionPopUpData.zipCodeData.state; + this.zipCodeCtu = shopQuestionPopUpData.zipCodeData.zipCodeCtu; + this.zipContainsMilitaryBase = + shopQuestionPopUpData.zipCodeData.containsMilitaryBase; } }, async getMoreScheduleData(startDate, endDate) { 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 a85b180f9..3b81966cc 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 @@ -122,35 +122,6 @@ export async function getShopProviderData(serviceZipCode) { ); } -export async function getAvailabilityRating( - startDate, - endDate, - shopAppointmentType, - providerNumber -) { - // For a given shop provider number and date range, get the appointment time slots available - const shopTimeSlots = await baseMixin.methods.dispatchStoreActionWithLogging( - storeActions.GET_SHOP_TIME_SLOTS, - { - providerNumber: providerNumber, - startDate: startDate, - endDate: endDate, - shopAppointmentType: shopAppointmentType, - }, - "service-location", - false - ); - - const numberOfDaysToEvaluate = 2; - const isGoodAvailability = - shopTimeSlots.data.days.filter((x) => x.timeSlots.length > 0).length >= - numberOfDaysToEvaluate; - - const shopStatus = isGoodAvailability ? "high" : "low"; - - return shopStatus; -} - export async function getClosestApplicableShops(serviceZipCode, carId, pageNameToLog) { if (!serviceZipCode) { return null; diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js index 06f34f125..6b21b2a96 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js @@ -1,8 +1,4 @@ -import { - getPricedMobileFeePart, - getServiceabilityDetails, - getAvailabilityRating, -} from "./service-location-helper"; +import { getPricedMobileFeePart, getServiceabilityDetails } from "./service-location-helper"; import { storeActions } from "@/constants/store-actions"; jest.mock("@/store", () => ({ @@ -320,38 +316,4 @@ describe("service-location-helper.js", () => { expect(result).toEqual(expected); }); }); - - describe("getAvailabilityRating", () => { - it("Should return a 'high' rating", async () => { - // Arrange - const providerNumber = "0000001"; - const expected = "high"; - // Act - const result = await getAvailabilityRating( - "2023-06-30", - "2023-07-06", - "Inshop", - providerNumber - ); - - // Assert - expect(result).toEqual(expected); - }); - - it("Should return a 'low' rating", async () => { - // Arrange - const providerNumber = "0000000"; - const expected = "low"; - // Act - const result = await getAvailabilityRating( - "2023-06-30", - "2023-07-06", - "Inshop", - providerNumber - ); - - // Assert - expect(result).toEqual(expected); - }); - }); }); diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 329b99840..38a61f222 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -148,11 +148,9 @@ import alert from "@/ux-components/alert/alert"; import serviceZipModalQuestion from "@/layouts/service-location/service-zip-modal-question/service-zip-modal-question"; import appointmentTypeQuestion from "@/layouts/service-location/appointment-type-question/appointment-type-question"; -import shopQuestion from "@/layouts/service-location/shop-question/shop-question"; import shopQuestionPopup from "@/layouts/service-location/shop-question/shop-question-popup"; import buttonQuestion from "@/digital-components/button-question/button-question.vue"; import shopListButton from "@/layouts/service-location/shop-question/shop-list-button/shop-list-button"; -import { getAvailabilityRating } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import navbar from "@/fmg-components/nav-bar/nav-bar"; @@ -163,7 +161,6 @@ import contentGroupModal from "@/fmg-components/content-group-modal/content-grou import textBlock from "@/digital-components/text-block/text-block"; // Supporting files -import baseMixin from "@/mixins/base-mixin.js"; import experimentMixin from "@/mixins/experiment-mixin.js"; import { experimentSettings } from "@/constants/experiments"; import { AppointmentTypeStrings } from "@/constants/schedule-constants"; @@ -450,17 +447,7 @@ export default { return this.displayNoShopsAlert || !this.isMobileAddressValid; }, additionalButtonData() { - const startDate = new Date(); - const endDate = new Date(); - endDate.setDate(startDate.getDate() + 6); - - const formattedStartDate = startDate.toISOString().split("T")[0]; - const formattedEndDate = endDate.toISOString().split("T")[0]; - return { - availabilityRatingCallback: getAvailabilityRating, - startDate: formattedStartDate, - endDate: formattedEndDate, shopAppointmentType: this.selectedAppointmentType, }; }, diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-question/service-zip-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-question/service-zip-question.vue index 8fe355923..0bc88799b 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-question/service-zip-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-question/service-zip-question.vue @@ -8,7 +8,6 @@ cornerStyle="rounded" mask="#####" :includeSearchIcon="includeSearchIcon" - @search-icon-click="$emit('search-icon-click')" :displayQuestionText="false" :isRequired="isRequired" :validationRules="computedValidationRules" /> diff --git a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue index 20accf43b..ece95aea6 100644 --- a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue +++ b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue @@ -58,15 +58,22 @@ export default { beforeMount() { if (this.displayAvailabilityIndicators) { this.displayLoader(); - const startDate = this.additionalButtonData.startDate; - const endDate = this.additionalButtonData.endDate; + const startDate = new Date(); + const endDate = new Date(); + endDate.setDate(startDate.getDate() + 6); + const formattedStartDate = startDate.toISOString().split("T")[0]; + const formattedEndDate = endDate.toISOString().split("T")[0]; + const shopAppointmentType = this.additionalButtonData.shopAppointmentType; - this.additionalButtonData - .availabilityRatingCallback(startDate, endDate, shopAppointmentType, this.value) - .then((data) => { - this.availabilityRating = data; - }); + this.getAvailabilityRating( + formattedStartDate, + formattedEndDate, + shopAppointmentType, + this.value + ).then((data) => { + this.availabilityRating = data; + }); } }, data() { @@ -103,6 +110,29 @@ export default { displayLoader() { this.isLoaderDisplayed = true; }, + async getAvailabilityRating(startDate, endDate, shopAppointmentType, providerNumber) { + // For a given shop provider number and date range, get the appointment time slots available + const shopTimeSlots = await this.dispatchStoreActionWithLogging( + this.storeActions.GET_SHOP_TIME_SLOTS, + { + providerNumber: providerNumber, + startDate: startDate, + endDate: endDate, + shopAppointmentType: shopAppointmentType, + }, + "service-location", + false + ); + + const numberOfDaysToEvaluate = 2; + const isGoodAvailability = + shopTimeSlots.data.days.filter((x) => x.timeSlots.length > 0).length >= + numberOfDaysToEvaluate; + + const shopStatus = isGoodAvailability ? "high" : "low"; + + return shopStatus; + }, }, components: { loader, diff --git a/src/layouts/service-location/shop-question/shop-question-popup.vue b/src/layouts/service-location/shop-question/shop-question-popup.vue index aa68dd8fc..e2a30c5c6 100644 --- a/src/layouts/service-location/shop-question/shop-question-popup.vue +++ b/src/layouts/service-location/shop-question/shop-question-popup.vue @@ -1,6 +1,6 @@