diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 0a67c8c96..fc94132d9 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -78,6 +78,10 @@ const endpoints = { url: "/parts/api/v1/parts/mobile-fee", method: "GET", }, + GetServiceabilityDetails: { + url: "/location/serviceability-details", + method: "GET", + }, GetSupportingItems: { url: "/parts/api/v1/parts/supporting-items", method: "POST", 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 444147b72..157c28f2b 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 @@ -30,7 +30,6 @@ export async function getPricedMobileFeePart(serviceZipCode) { } export async function getServiceabilityDetails(serviceZipCode, lineItems) { - // Get the Mobile Fee Part const serviceabilityDetails = await baseMixin.methods.dispatchStoreAction( storeActions.GET_SERVICEABILITY_DETAILS, @@ -40,6 +39,6 @@ export async function getServiceabilityDetails(serviceZipCode, lineItems) { }, false ); - const temp = Promise.resolve(serviceabilityDetails) + return Promise.resolve(serviceabilityDetails); } diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index ac1be453d..531f17acf 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -90,7 +90,7 @@ export default { default: () => ({}), }, isZipServiceableMobile: Boolean, - isZipServiceableInShop: Boolean, + isZipServiceableInshop: Boolean, linkWidgetName: String, modalWidgetName: String, alertNonServiceableZipWidgetName: String, diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 0fe9e54af..889094264 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -19,6 +19,10 @@ alertClass="alert-warning" /> { - this.zipContainsMilitaryBase = r.containsMilitaryBase; + zipCode: { + async handler(newValue, oldValue) { + if (newValue !== oldValue) { + baseMixin.methods.getZipCodeData(newValue).then((r) => { + this.zipContainsMilitaryBase = r.containsMilitaryBase; + }); + } + + const lineItems = store.getters.order.lineItems; + const serviceabilityDetails = await getServiceabilityDetails({ + serviceZipCode: newValue, + lineItems: lineItems, }); + + this.setServiceabilityDetails(serviceabilityDetails.data); } - }, + } }, components: { alert, diff --git a/src/layouts/service-location/service-type-question/service-type-question.vue b/src/layouts/service-location/service-type-question/service-type-question.vue index f3f73415e..f75ce94cf 100644 --- a/src/layouts/service-location/service-type-question/service-type-question.vue +++ b/src/layouts/service-location/service-type-question/service-type-question.vue @@ -29,8 +29,8 @@ export default { validationRules: String, cmsWidgetName: String, isGlassServiceableMobile: Boolean, - isGlassServiceableInShop: Boolean, - isRecalibrationServiceableInShop: Boolean, + isGlassServiceableInshop: Boolean, + isRecalibrationServiceableInshop: Boolean, isRecalibrationServiceableMobile: Boolean, }, setup() { @@ -49,40 +49,54 @@ export default { }, answersToDisplay() { let filteredAnswers; - if ( - this.isGlassServiceableMobile && - this.isRecalibrationServiceableMobile && - this.isGlassServiceableInShop && - this.isRecalibrationServiceableInShop - ) { + if (this.serviceability == "All") { filteredAnswers = this.answersFromCms; - } else if ( - this.isGlassServiceableMobile && - this.isRecalibrationServiceableMobile && - !this.isGlassServiceableInShop && - !this.isRecalibrationServiceableInShop - ) { - filteredAnswers = this.answersFromCms.filter( - (answer) => answer.Name == "InShop" || answer.Name == "DropOff" - ); - } else if ( - this.isGlassServiceableInShop && - this.isRecalibrationServiceableInShop && - !this.isGlassServiceableMobile && - !this.isRecalibrationServiceableMobile - ) { + } else if (this.serviceability == "MobileOnly") { filteredAnswers = this.answersFromCms.filter((answer) => answer.Name == "Mobile"); - } else if ( - !this.isGlassServiceableInShop && - !this.isRecalibrationServiceableInShop && - !this.isGlassServiceableMobile && - !this.isRecalibrationServiceableMobile - ) { + } else if (this.serviceability == "InshopOnly") { + filteredAnswers = this.answersFromCms.filter( + (answer) => answer.Name == "Inshop" || answer.Name == "DropOff" + ); + } else if (this.serviceability == "None") { filteredAnswers = []; } return filteredAnswers; }, + serviceability() { + let result; + if ( + this.isGlassServiceableMobile && + this.isRecalibrationServiceableMobile && + this.isGlassServiceableInshop && + this.isRecalibrationServiceableInshop + ) { + result = "All"; + } else if ( + !this.isGlassServiceableInshop && + !this.isRecalibrationServiceableInshop && + this.isGlassServiceableMobile && + this.isRecalibrationServiceableMobile + ) { + result = "MobileOnly" + } else if ( + this.isGlassServiceableInshop && + this.isRecalibrationServiceableInshop && + !this.isGlassServiceableMobile && + !this.isRecalibrationServiceableMobile + ) { + result = "InshopOnly" + } else if ( + !this.isGlassServiceableInshop && + !this.isRecalibrationServiceableInshop && + !this.isGlassServiceableMobile && + !this.isRecalibrationServiceableMobile + ) { + result = "None" + } + + return result; + }, selectedValues: { get: function () { return this.modelValue; @@ -92,6 +106,17 @@ export default { }, }, }, + watch: { + serviceability: { + handler(newValue, oldValue) { + if (newValue == "MobileOnly") { + this.selectedValues = "Mobile"; + } else { + this.selectedValues = null; + } + } + } + }, components: { buttonQuestion, }, diff --git a/src/store/index.js b/src/store/index.js index b7f3fcf03..5a0e86846 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -931,8 +931,9 @@ export const actions = { method: endpoints.GetServiceabilityDetails.method, //TODO: Remove Mocky Endpoints //endpoint: "https://run.mocky.io/v3/59e1a644-cf16-4f08-8069-1ab2a1e38f79", // NoShopsAvailable - endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInShop + //endpoint: "https://run.mocky.io/v3/4fe1fb89-dd56-4e4a-9af2-96bd1ab77847", // ForcedInshop //endpoint: "https://run.mocky.io/v3/e2eaa097-6ea5-4906-af53-901edaa94939", // ForcedMobile + endpoint: "https://run.mocky.io/v3/1811a1fe-12a7-48f3-939e-d10a9b77dd25", // All Options }); },