From d4a938f3c3f540c3ef6b81671d0ca799bdb42fd3 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 17 Mar 2023 14:42:28 -0400 Subject: [PATCH] WIP --- src/constants/error-messages.js | 1 + .../mobile-location-modal-questions.vue | 40 +++++++++++++++++ .../service-location/service-location.vue | 45 ++++++++++++++++--- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index 5631b44c7..739698861 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -18,6 +18,7 @@ const errorMessages = { LAST_NAME_REQUIRED: "Please enter your last name", EMAIL_ADDRESS_REQUIRED: "Please enter your email address", EMAIL_ADDRESS_FORMAT: "Please enter a valid email address", + SERVICE_ADDRESS_REQUIRED: "Please enter your service address", SERVICE_ZIP_REQUIRED: "Please enter your service ZIP", SERVICE_ZIP_FORMAT: "Please enter a valid service ZIP", VIN_REQUIRED: "Please enter your VIN", 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 586e1c6de..46cb51d13 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 @@ -22,6 +22,9 @@ cmsWidgetName="MobileFeeDisclaimerWidget" typeStyle="caption" /> +
+ {{ errorMessage }} +
+ modalWidgetName="MobileLocationModalWidget" + validationRules="service-address-required"/> @@ -42,7 +43,7 @@ import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; -import { Form } from "vee-validate"; +import { Form, defineRule } from "vee-validate"; // Supporting files import baseMixin from "@/mixins/base-mixin.js"; @@ -50,8 +51,24 @@ import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; +import { errorMessages } from "@/constants/error-messages"; import store from "@/store"; +defineRule("service-address-required", (value) => { + const isValid = + value.addressQuestions.streetAddress !== "" && + value.addressQuestions.city !== "" && + value.addressQuestions.state !== "" && + value.addressQuestions.zipCode !== "" && + value.isVehicleProtected !== null; + + if (!isValid) { + return errorMessages.SERVICE_ADDRESS_REQUIRED; + } + + return isValid; +}); + export default { name: "service-location", data() { @@ -139,6 +156,12 @@ export default { this.state = newValue.addressQuestions.state; this.zipCode = newValue.addressQuestions.zipCode; this.isVehicleProtected = newValue.isVehicleProtected; + + // setErrors({ + // mobileLocationQuestions: "" + // }); + + //this.$refs.theForm.setTouched({}); }, }, shouldDisableForwardAction() { @@ -147,6 +170,7 @@ export default { }, methods: { arePagePrerequisitesValid() { + return ( store.getters.lineItems.supportingItems !== null && store.getters.order.serviceLocation.zipCode !== null && @@ -188,9 +212,9 @@ export default { }, }, watch: { - zipCode(current, previous) { - if (current !== previous) { - baseMixin.methods.getZipCodeData(current).then((r) => { + zipCode(newValue, oldValue) { + if (newValue !== oldValue) { + baseMixin.methods.getZipCodeData(newValue).then((r) => { this.zipContainsMilitaryBase = r.containsMilitaryBase; }); } @@ -208,3 +232,12 @@ export default { }, }; + +