Adding validations to lpl
This commit is contained in:
parent
7beb7ff4d3
commit
c007430e63
5 changed files with 108 additions and 45 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
<div class="row d-flex flex-row-reverse align-items-center">
|
<div class="row d-flex flex-row-reverse align-items-center">
|
||||||
<div class="col button-col d-flex" id="stacked">
|
<div class="col button-col d-flex" id="stacked">
|
||||||
<buttonMain
|
<buttonMain
|
||||||
|
ref="buttonMain"
|
||||||
isPrimary
|
isPrimary
|
||||||
:buttonText="buttonText"
|
:buttonText="buttonText"
|
||||||
loaderColor="white"
|
loaderColor="white"
|
||||||
|
|
@ -77,6 +78,12 @@ export default {
|
||||||
this.backLink = cmsContent.BackButtonText;
|
this.backLink = cmsContent.BackButtonText;
|
||||||
this.buttonText = cmsContent.ForwardButtonText;
|
this.buttonText = cmsContent.ForwardButtonText;
|
||||||
},
|
},
|
||||||
|
updateButtonText(newText) {
|
||||||
|
this.buttonText = newText;
|
||||||
|
},
|
||||||
|
removeLoader(){
|
||||||
|
this.$refs.buttonMain.removeLoader();
|
||||||
|
},
|
||||||
buttonClick() {
|
buttonClick() {
|
||||||
this.$emit("ForwardClicked");
|
this.$emit("ForwardClicked");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ const errorMessages = {
|
||||||
CITY_REQUIRED: "Please enter your city",
|
CITY_REQUIRED: "Please enter your city",
|
||||||
STATE_REQUIRED: "Please enter your state",
|
STATE_REQUIRED: "Please enter your state",
|
||||||
ZIP_REQUIRED: "Please enter your ZIP",
|
ZIP_REQUIRED: "Please enter your ZIP",
|
||||||
|
LICENSE_PLATE_REQUIRED: "Please enter your license plate number",
|
||||||
FIRST_NAME_REQUIRED: "Please enter your first name",
|
FIRST_NAME_REQUIRED: "Please enter your first name",
|
||||||
LAST_NAME_REQUIRED: "Please enter your last name",
|
LAST_NAME_REQUIRED: "Please enter your last name",
|
||||||
EMAIL_ADDRESS_REQUIRED: "Please enter your email address",
|
EMAIL_ADDRESS_REQUIRED: "Please enter your email address",
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,63 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall">
|
<Form
|
||||||
<funnelHeader ref="funnelHeader" />
|
@submit="onSubmit"
|
||||||
<vehicleBanner ref="vehicleBanner" :displayGenericVehicleImage="false" />
|
@invalid-submit="onInvalidSubmit"
|
||||||
<funnelSubHeader ref="funnelSubHeader" />
|
ref="theForm"
|
||||||
<input type="text" id="license_plate" v-model="licensePlate">
|
v-slot="{ meta }"
|
||||||
<input type="text" id="zip" v-model="zip">
|
>
|
||||||
<input type="text" id="email" v-model="email">
|
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||||
<alert
|
<funnelHeader ref="funnelHeader" />
|
||||||
class="my-3"
|
<vehicleBanner ref="vehicleBanner" :displayGenericVehicleImage="false" />
|
||||||
v-if="newServiceZipRequired"
|
<funnelSubHeader ref="funnelSubHeader" />
|
||||||
alertClass="alert-danger"
|
<div class="row my-2">
|
||||||
:alertHeadline="noServiceZipWidget.headline"
|
<div class="col">
|
||||||
:alertCopy="noServiceZipWidget.copy"
|
<textboxQuestion ref="LicensePlateNumber" v-model="licensePlate" inputId="license_plate" disableAutoFill validationRules="license-plate-required" />
|
||||||
/>
|
</div>
|
||||||
<alert
|
</div>
|
||||||
class="my-3"
|
<div class="row my-2">
|
||||||
v-if="vinNotValid"
|
<div class="col">
|
||||||
alertClass="alert-danger"
|
<textboxQuestion ref="RegistrationZip" v-model="zip" inputId="zip" mask="#####" disableAutoFill validationRules="zip-required" />
|
||||||
:alertHeadline="noMatchAlertWidget.headline"
|
</div>
|
||||||
:alertCopy="noMatchAlertWidget.copy"
|
</div>
|
||||||
/>
|
<div class="row my-2">
|
||||||
<alert
|
<div class="col">
|
||||||
class="my-3"
|
<textboxQuestion ref="EmailAddress" v-model="email" inputId="email" disableAutoFill validationRules="email-address-required|email-address-format" />
|
||||||
v-if="vinDoesNotMatchCarId"
|
</div>
|
||||||
alertClass="alert-danger"
|
</div>
|
||||||
:alertHeadline="matchedDifferentVehicleAlertWidget.headline"
|
<alert
|
||||||
:alertCopy="matchedDifferentVehicleAlertWidget.copy"
|
class="my-3"
|
||||||
/>
|
v-if="newServiceZipRequired"
|
||||||
<funnelFooter
|
alertClass="alert-danger"
|
||||||
ref="funnelFooter"
|
:alertHeadline="noServiceZipWidget.headline"
|
||||||
@back-clicked="backButtonAction"
|
:alertCopy="noServiceZipWidget.copy"
|
||||||
@ForwardClicked="forwardButtonAction"
|
/>
|
||||||
/>
|
<alert
|
||||||
</div>
|
class="my-3"
|
||||||
|
v-if="vinNotValid"
|
||||||
|
alertClass="alert-danger"
|
||||||
|
:alertHeadline="noMatchAlertWidget.headline"
|
||||||
|
:alertCopy="noMatchAlertWidget.copy"
|
||||||
|
/>
|
||||||
|
<alert
|
||||||
|
class="my-3"
|
||||||
|
v-if="vinDoesNotMatchCarId"
|
||||||
|
alertClass="alert-warning"
|
||||||
|
:alertHeadline="matchedDifferentVehicleAlertWidget.headline"
|
||||||
|
:alertCopy="matchedDifferentVehicleAlertWidget.copy"
|
||||||
|
/>
|
||||||
|
<div class="row my-2">
|
||||||
|
<div class="col">
|
||||||
|
<textboxQuestion v-if="newServiceZipRequired" questionText="Service area ZIP code" v-model="serviceZip" inputId="serviceZip" disableAutoFill validationRules="zip-required" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<funnelFooter
|
||||||
|
ref="funnelFooter"
|
||||||
|
:isDisabled="!meta.valid"
|
||||||
|
@back-clicked="backButtonAction"
|
||||||
|
@ForwardClicked="forwardButtonAction"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -42,6 +67,7 @@ import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
|
||||||
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
|
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
|
@ -50,6 +76,15 @@ import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
import { required, regex } from "@/helpers/validation-rules";
|
||||||
|
import { Form, defineRule } from "vee-validate";
|
||||||
|
|
||||||
|
// DEFINE VALIDATION RULES
|
||||||
|
defineRule("license-plate-required", required(errorMessages.LICENSE_PLATE_REQUIRED));
|
||||||
|
defineRule("zip-required", required(errorMessages.ZIP_REQUIRED));
|
||||||
|
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED));
|
||||||
|
defineRule("email-address-format", regex(/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+).([a-zA-Z]{2,})$/, errorMessages.EMAIL_ADDRESS_FORMAT));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "license-plate-lookup",
|
name: "license-plate-lookup",
|
||||||
|
|
@ -78,6 +113,15 @@ export default {
|
||||||
vm.$refs.funnelSubHeader.initializeComponent(
|
vm.$refs.funnelSubHeader.initializeComponent(
|
||||||
resultMap.cmsContent.FunnelSubHeaderWidget
|
resultMap.cmsContent.FunnelSubHeaderWidget
|
||||||
);
|
);
|
||||||
|
vm.$refs.LicensePlateNumber.initializeComponent(
|
||||||
|
resultMap.cmsContent.LicensePlateNumber.QuestionText
|
||||||
|
);
|
||||||
|
vm.$refs.RegistrationZip.initializeComponent(
|
||||||
|
resultMap.cmsContent.RegistrationZip.QuestionText
|
||||||
|
);
|
||||||
|
vm.$refs.EmailAddress.initializeComponent(
|
||||||
|
resultMap.cmsContent.EmailAddress.QuestionText
|
||||||
|
);
|
||||||
vm.$refs.funnelFooter.initializeComponent(
|
vm.$refs.funnelFooter.initializeComponent(
|
||||||
resultMap.cmsContent.FunnelFooterWidget
|
resultMap.cmsContent.FunnelFooterWidget
|
||||||
);
|
);
|
||||||
|
|
@ -95,14 +139,18 @@ export default {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
validationRules: String,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
newServiceZipRequired: false,
|
newServiceZipRequired: false,
|
||||||
vinNotValid: false,
|
vinNotValid: false,
|
||||||
vinDoesNotMatchCarId: false,
|
vinDoesNotMatchCarId: false,
|
||||||
licensePlate: 'HWV4445',
|
licensePlate: '',
|
||||||
zip: '43224',
|
zip: '',
|
||||||
email: 'maxjdempsey@gmail.com',
|
email: '',
|
||||||
|
serviceZip: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -117,21 +165,23 @@ export default {
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
// route to move backwards
|
|
||||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
const zipValidation = await this.validateZip(this.zip);
|
const zipValidation = this.serviceZip ? await this.validateZip(this.serviceZip) : await this.validateZip(this.zip);
|
||||||
if (!zipValidation.data.isServiceable) {
|
if (!zipValidation.data.isServiceable) {
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
this.newServiceZipRequired = true;
|
this.newServiceZipRequired = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const vinLookup = await this.lookupVin(this.licensePlate, zipValidation.data.state);
|
const vinLookup = await this.lookupVin(this.licensePlate, zipValidation.data.state).catch(() => {
|
||||||
if (!vinLookup.data.vin) {
|
this.$refs.funnelFooter.removeLoader();
|
||||||
this.vinNotValid = true;
|
this.vinNotValid = true;
|
||||||
return;
|
return;
|
||||||
}
|
});
|
||||||
if (vinLookup.data.vehicle.carId !== store.getters.vehicle.carId) {
|
if (vinLookup.data.vehicle.carId !== store.getters.vehicle.carId) {
|
||||||
|
this.$refs.funnelFooter.updateButtonText(`Continue with ${vinLookup.data.vin} ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`);
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
this.vinDoesNotMatchCarId = true;
|
this.vinDoesNotMatchCarId = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -193,11 +243,13 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
Form,
|
||||||
funnelHeader,
|
funnelHeader,
|
||||||
funnelFooter,
|
|
||||||
vehicleBanner,
|
vehicleBanner,
|
||||||
alert,
|
|
||||||
funnelSubHeader,
|
funnelSubHeader,
|
||||||
|
textboxQuestion,
|
||||||
|
alert,
|
||||||
|
funnelFooter,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
ref="theForm"
|
ref="theForm"
|
||||||
v-slot="{ meta }"
|
v-slot="{ meta }"
|
||||||
>
|
>
|
||||||
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall">
|
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||||
<funnelHeader ref="funnelHeader" />
|
<funnelHeader ref="funnelHeader" />
|
||||||
<vehicleBanner ref="vehicleBanner" :displayGenericVehicleImage=false />
|
<vehicleBanner ref="vehicleBanner" :displayGenericVehicleImage=false />
|
||||||
<funnelSubHeader ref="funnelSubHeader" />
|
<funnelSubHeader ref="funnelSubHeader" />
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
removeLoader(){
|
||||||
|
this.isLoaderDisplayed = false;
|
||||||
|
},
|
||||||
clicked() {
|
clicked() {
|
||||||
if (!this.isDisabled) {
|
if (!this.isDisabled) {
|
||||||
this.isLoaderDisplayed = true;
|
this.isLoaderDisplayed = true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue