License Plate Lookup refactoring. Refactor mostly complete. There might be some slight differences remaining

This commit is contained in:
Leah Schumann 2022-07-13 09:14:34 -04:00
parent e452928c77
commit 8247c5b9e3
2 changed files with 31 additions and 23 deletions

View file

@ -17,7 +17,7 @@
<div class="row my-2">
<div class="col">
<textboxQuestion
cmsWidgetName="LicensePlateNumber"
cmsWidgetName="LicensePlateNumberQuestionWidget"
v-model="licensePlate"
isRequired
inputId="license_plate"
@ -28,8 +28,8 @@
<div class="row my-2">
<div class="col">
<textboxQuestion
cmsWidgetName="RegistrationZip"
v-model="registrationZip"
cmsWidgetName="RegistrationZipQuestionWidget"
v-model="registrationZipCode"
inputId="zip"
mask="#####"
validationRules="zip-required|zip-format"
@ -39,7 +39,7 @@
<div class="row my-2">
<div class="col">
<textboxQuestion
cmsWidgetName="EmailAddress"
cmsWidgetName="EmailAddressQuestionWidget"
v-model="email"
inputId="email"
validationRules="email-address-required|email-address-format"
@ -65,17 +65,18 @@
<div class="col">
<textboxQuestion
v-if="showServiceZipField"
cmsWidgetName="ServiceZip"
cmsWidgetName="ServiceZipQuestionWidget"
v-model="serviceZipCode"
inputId="serviceZipCode"
validationRules="zip-required|zip-format"
mask="#####"
/>
</div>
</div>
<alert
v-if="displayVinNotFoundAlert"
class="my-3"
cmsWidgetName="NoMatchAlertWidget"
cmsWidgetName="AlertVinNotFoundWidget"
alertClass="alert-warning"
v-bind:isDismissible="false"
/>
@ -155,7 +156,7 @@ export default {
data() {
return {
licensePlate: this.getLicensePlateFromStore(),
registrationZip: this.getRegistrationZipFromStore(),
registrationZipCode: this.getRegistrationZipFromStore(),
email: this.getEmailFromStore(),
serviceZipCode: this.getServiceZipFromStore(),
displayNonServiceableZipAlert: false,
@ -206,7 +207,7 @@ export default {
async forwardButtonAction() {
this.resetWarningsAndErrors();
const registrationZipValidationResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.registrationZip });
const registrationZipValidationResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { zip: this.registrationZipCode });
// Settle promises and get results
const promiseResultMap = [
@ -216,7 +217,7 @@ export default {
},
{
resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode ? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode }) : registrationZipValidationResponse,
promise: this.serviceZipCode ? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { zip: this.serviceZipCode }) : registrationZipValidationResponse,
}
];
@ -225,11 +226,15 @@ export default {
// Lookup vin
const vinLookup = await this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE, {licensePlate: this.licensePlate, licenseState: resultMap.registrationZipValidationResponse.state}, false)
.catch(() => {
// No VINS found.
// No VIN found.
this.displayVinNotFoundAlert = true;
return this.$refs.funnelFooter.removeLoader();
});
// If no VIN was found, stop processing after displaying alert
if (!vinLookup) {
return;
}
// If a Service Zip is entered and it is an invalid zip code (ex. 11111) then show an alert
const isZipValid = resultMap.serviceZipValidationResponse.isValid;
@ -268,7 +273,7 @@ export default {
// If the registration zip code is serviceable and nothing was entered for the service zip code
// then set the service zip code to the registration zip code
if (!this.serviceZipCode) {
this.serviceZipCode = this.registrationZip;
this.serviceZipCode = this.registrationZipCode;
}
// Save vin, vehicle, customer, service and registration information
@ -278,7 +283,7 @@ export default {
registrationInfo: {
licensePlate: this.licensePlate,
state: resultMap.registrationZipValidationResponse.state,
zipCode: this.registrationZip,
zipCode: this.registrationZipCode,
}
}, false);
@ -300,10 +305,10 @@ export default {
},
resetWarningsAndErrors() {
this.displayVinNotFoundAlert = false;
this.displayNonServiceableZipAlert = false;
this.displayMatchedDifferentVehicleAlert = false;
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
this.displayVinNotFoundAlert = false;
this.displayNonServiceableZipAlert = false;
this.displayMatchedDifferentVehicleAlert = false;
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
},
},
@ -312,18 +317,18 @@ export default {
},
computed: {
AlertNonServiceableZipHeader() {
const zipCode = this.serviceZipCode ? this.serviceZipCode : this.registrationZipCode;
const text = this.getCmsContent("AlertNonServiceableZipWidget", "HeadlineText").replaceAll("{custom:serviceZip}", zipCode);
return text;
const zipCode = this.serviceZipCode ? this.serviceZipCode : this.registrationZipCode;
const text = this.getCmsContent("AlertNonServiceableZipWidget", "HeadlineText").replaceAll("{custom:serviceZip}", zipCode);
return text;
},
AlertNonServiceableZipBody() {
return this.getCmsContent("AlertNonServiceableZipWidget", "BodyText");
return this.getCmsContent("AlertNonServiceableZipWidget", "BodyText");
},
AlertMatchedDifferentVehicleHeader() {
return this.getCmsContent("MatchedDifferentVehicleAlertWidget", "HeadlineText").replaceAll("{custom:damage}", getDamageString());
return this.getCmsContent("AlertMatchedDifferentVehicleWidget", "HeadlineText").replaceAll("{custom:damage}", getDamageString());
},
AlertMatchedDifferentVehicleBody() {
return this.getCmsContent("MatchedDifferentVehicleAlertWidget", "BodyText")
return this.getCmsContent("AlertMatchedDifferentVehicleWidget", "BodyText")
.replaceAll("{custom:damage}", getDamageString())
.replaceAll("{custom:plateLookupYear}", this.customAlertData?.vehicleInfo?.year)
.replaceAll("{custom:plateLookupMake}", this.customAlertData?.vehicleInfo?.make)
@ -336,12 +341,14 @@ export default {
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
);
},
registrationZip() {
registrationZipCode() {
this.$refs.funnelFooter.updateButtonText(
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
);
},
serviceZipCode() {
// If they modify the service zip code, then hide the error message.
this.displayNonServiceableZipAlert = false;
this.$refs.funnelFooter.updateButtonText(
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
);

View file

@ -316,6 +316,7 @@ export default {
this.displayNonServiceableZipAlert = true;
return this.$refs.funnelFooter.removeLoader();
},
async navigateForward(){
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {