WIP vin-lookup page.

This commit is contained in:
bmauger 2022-04-28 09:59:08 -04:00
parent 9623fd80bb
commit d0fb0ee541
2 changed files with 68 additions and 43 deletions

View file

@ -95,7 +95,7 @@ async function getLatestPageForRedirection() {
if (store.getters.vehicle.vin) { if (store.getters.vehicle.vin) {
return fmgPageValues.LICENSE_PLATE_LOOKUP; return fmgPageValues.LICENSE_PLATE_LOOKUP;
} else { } else {
return fmgPageValues.ESTIMATE; return fmgPageValues.VIN_LOOKUP;
} }
} }
} }

View file

@ -31,10 +31,11 @@
</div> </div>
<alert <alert
class="my-3" class="my-3"
:manualHeadline="MatchedDifferentVehicleAlertHeader"
:manualCopy="MatchedDifferentVehicleAlertBody"
v-model="customAlertData" v-model="customAlertData"
v-if="matchedDifferentVehicle" v-if="matchedDifferentVehicle"
alertClass="alert-danger" alertClass="alert-danger"
cmsWidgetName="MatchedDifferentVehicle"
/> />
<alert <alert
class="my-3" class="my-3"
@ -45,24 +46,11 @@
/> />
<alert <alert
class="my-3" class="my-3"
:manualHeadline="NoServiceZipHeader"
:manualCopy="NoServiceZipBody"
v-model="customAlertData" v-model="customAlertData"
v-if="noServiceZip" v-if="noServiceZip"
alertClass="alert-warning" alertClass="alert-warning"
cmsWidgetName="NoServiceZipWidget"
/>
<alert
class="my-3"
v-model="customAlertData"
v-if="vinFound"
alertClass="alert-warning"
cmsWidgetName="VinFoundWidget"
/>
<alert
class="my-3"
v-model="customAlertData"
v-if="vinFoundReadOnly"
alertClass="alert-warning"
cmsWidgetName="VinFoundReadOnlyWidget"
/> />
<alert <alert
class="my-3" class="my-3"
@ -114,6 +102,7 @@ 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 { errorMessages } from "@/constants/error-messages";
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
import { required, regex } from "@/helpers/validation-rules"; import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
@ -163,8 +152,43 @@ export default {
zip: '', zip: '',
email: '', email: '',
customAlertData: {}, customAlertData: {},
isCarIdDifferent: false,
previouslyEnteredCarId: '',
}; };
}, },
computed: {
MatchedDifferentVehicleAlertHeader(){
let text = this.getCmsContent("MatchedDifferentVehicle",
"HeadlineText").replaceAll("{custom:damage}", getDamageString());
return text;
},
MatchedDifferentVehicleAlertBody(){
let text = this.getCmsContent("MatchedDifferentVehicle",
"BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:vinlookupModel}",
this.customAlertData?.vehicleInfo?.model);
return text;
},
NoServiceZipHeader(){
let text = this.getCmsContent("NoServiceZipWidget", "HeadlineText").replaceAll("{custom:serviceZip}", this.zip);
return text;
},
NoServiceZipBody(){
return this.getCmsContent("NoServiceZipWidget", "BodyText");
},
PerfectMatchNewVinAlertHeader() {
return this.getCmsContent("PerfectMatchNewVinAlert", "HeadlineText");
},
PerfectMatchNewVinAlertBody() {
return this.getCmsContent("PerfectMatchNewVinAlert", "BodyText").replaceAll("{custom:damage}",
getDamageString())
},
isVinFieldReadOnly(){
return this.$store.getters.payment.insuranceCoverage.isVerified;
},
},
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return store.getters.vehicle.carId !== null; return store.getters.vehicle.carId !== null;
@ -187,30 +211,36 @@ export default {
this.noServiceZip = true; this.noServiceZip = true;
return; return;
} }
const vinLookup = await this.lookupVin(this.vin).catch(() => { const vehicleLookup = await this.lookupVehicle(this.vin).catch(() => {
this.vinNotFound = true;
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
this.noMatchAlert = true;
return; return;
}); });
if (vinLookup.data.carId !== store.getters.vehicle.carId) { this.isCarIdDifferent = vehicleLookup.data.carId !== store.getters.vehicle.carId;
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
if (this.isCarIdDifferent && (vehicleLookup.data.carId !== this.previouslyEnteredCarId)) {
this.previouslyEnteredCarId = vehicleLookup.data.carId;
this.customAlertData.vehicleInfo = vehicleLookup.data;
this.$refs.funnelFooter.updateButtonText(`Continue with ${vehicleLookup.data.year} ${vehicleLookup.data.make} ${vehicleLookup.data.model}`);
this.isVinValid = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleLookup.data.carId);
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
this.foundWindshieldAlert = true; this.matchedDifferentVehicle = true;
return; return;
} };
const carInfo = this.vinDoesNotMatchCarId ? vinLookup.data : store.getters.vehicle; //const carInfo = this.vinDoesNotMatchCarId ? vehicleLookup.data : store.getters.vehicle;
this.updateStore(carInfo) //this.updateStore(carInfo)
const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction( // const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(
this.storeActions.GET_PARTS_OR_QUESTIONS, // this.storeActions.GET_PARTS_OR_QUESTIONS,
{ // {
carId: store.getters.vehicle.carId, // carId: store.getters.vehicle.carId,
glassArray: store.getters.damage.glassToReplace, // glassArray: store.getters.damage.glassToReplace,
zipCode: this.zip, // zipCode: this.zip,
vin: vinLookup.vin // vin: vehicleLookup.vin
}, // },
false // false
); // );
this.navigateForward(partsData); // this.navigateForward(partsData);
}, },
navigateForward(partsData){ navigateForward(partsData){
if(partsData.data.partsOrQuestions[0].partQuestions && partsData.data.partsOrQuestions[0].partQuestions.length > 0){ if(partsData.data.partsOrQuestions[0].partQuestions && partsData.data.partsOrQuestions[0].partQuestions.length > 0){
@ -229,7 +259,7 @@ export default {
{ zip } { zip }
); );
}, },
lookupVin(vin) { lookupVehicle(vin) {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchNonBlockingStoreAction(
storeActions.LOOKUP_VEHICLE_BY_VIN, storeActions.LOOKUP_VEHICLE_BY_VIN,
{ vin } { vin }
@ -253,11 +283,6 @@ export default {
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email); store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
}, },
}, },
computed: {
isVinFieldReadOnly(){
return this.$store.getters.payment.insuranceCoverage.isVerified;
}
},
components: { components: {
Form, Form,
funnelHeader, funnelHeader,