Vin Masking when returning to Vin Lookup page after returning from heritage funnel

This commit is contained in:
Leah Schumann 2022-06-10 15:18:43 -04:00
parent 78f66ddd86
commit 273f2c4ca7
2 changed files with 32 additions and 6 deletions

View file

@ -20,6 +20,7 @@
@change="handleChange" @change="handleChange"
@blur="handleChange" @blur="handleChange"
:maxlength="maxLength ? maxLength : '999'" :maxlength="maxLength ? maxLength : '999'"
@focus="$emit('focus', $event.target.value)"
/> />
<div v-show="errorMessage" class="row my-2 form-test-error"> <div v-show="errorMessage" class="row my-2 form-test-error">
<span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span> <span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span>

View file

@ -25,6 +25,8 @@
validationRules="vin-required|vin-format" validationRules="vin-required|vin-format"
:isDisabled="isVinFieldReadOnly" :isDisabled="isVinFieldReadOnly"
maxLength="17" maxLength="17"
:mask="vinMask"
@focus="setVinTouched"
/> />
</div> </div>
</div> </div>
@ -183,10 +185,14 @@ export default {
previouslyEnteredCarId: '', previouslyEnteredCarId: '',
invalidZip: '', invalidZip: '',
vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0,
initialVin: this.getVinFromStore(),
}; };
}, },
mounted() { mounted() {
this.attachCustomEvents(); this.attachCustomEvents();
if (this.vinPopulatedOnPageLoad) {
this.setupVinMask();
}
}, },
watch: { watch: {
vin() { vin() {
@ -194,13 +200,13 @@ export default {
this.$refs.funnelFooter.updateButtonText( this.$refs.funnelFooter.updateButtonText(
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText") this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
); );
} },
}, },
computed: { computed: {
perfectMatchNewVinAlert() { perfectMatchNewVinAlert() {
const isVinPerfectMatch = this.vinPopulatedOnPageLoad && this.vin === this.getVinFromStore(); const isVinPerfectMatch = this.vinPopulatedOnPageLoad && this.vin === this.getVinFromStore();
this.updateIsCarIdDifferent(isVinPerfectMatch); this.updateIsCarIdDifferent(isVinPerfectMatch);
return isVinPerfectMatch; return isVinPerfectMatch;
}, },
MatchedDifferentVehicleAlertHeader(){ MatchedDifferentVehicleAlertHeader(){
const text = this.getCmsContent("MatchedDifferentVehicle", const text = this.getCmsContent("MatchedDifferentVehicle",
@ -238,10 +244,18 @@ export default {
getIsWindshieldOnly()) getIsWindshieldOnly())
}, },
isVinFieldReadOnly(){ isVinFieldReadOnly(){
return this.$store.getters.payment.insuranceCoverage.isVerified || getFunnelCookie().HasDelayedClaimRegistration; return this.$store.getters.payment.insuranceCoverage.isVerified || getFunnelCookie().HasDelayedClaimRegistration;
}, },
}, },
methods: { methods: {
setVinTouched() {
this.vinMask = "XXXXXXXXXXXXXXXXX";
this.vin = this.initialVin;
},
setupVinMask() {
const lastSixChars = this.initialVin.substring(11, this.initialVin.length);
this.vinMask = `!X!X!X!X!X!X!X!X!X!X!X${lastSixChars}`;
},
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null; return store.getters.vehicle.carId !== null;
}, },
@ -285,8 +299,15 @@ export default {
} }
}, },
async forwardButtonAction() { async forwardButtonAction() {
// If there is no change to the VIN entered then navigate forward without performing lookup.
if (this.vinPopulatedOnPageLoad && this.vin == this.initialVin) {
this.navigateForward();
return;
}
const zipValidation = this.validateZip(this.zip); const zipValidation = this.validateZip(this.zip);
const vehicleLookup = this.lookupVehicle(this.vin); const vehicleLookup = this.lookupVehicle(this.vin);
const zipValidationResponse = await zipValidation; const zipValidationResponse = await zipValidation;
const vehicleLookupResponse = await vehicleLookup.catch(() => { const vehicleLookupResponse = await vehicleLookup.catch(() => {
this.vinNotFound = true; this.vinNotFound = true;
@ -294,6 +315,7 @@ export default {
this.noServiceZip = false; this.noServiceZip = false;
return; return;
}); });
if (!zipValidationResponse.data.isServiceable) { if (!zipValidationResponse.data.isServiceable) {
this.customAlertData.zip = this.zip; this.customAlertData.zip = this.zip;
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
@ -301,6 +323,7 @@ export default {
this.invalidZip = this.zip; this.invalidZip = this.zip;
return; return;
} }
this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId;
if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) { if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {
@ -314,11 +337,13 @@ export default {
this.isCarIdDifferent = true; this.isCarIdDifferent = true;
return; return;
} }
this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data);
this.navigateForward(); this.navigateForward();
}, },
navigateForward(){ navigateForward(){
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {}); this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {});
return; return;
} else { } else {