This commit is contained in:
Jason Wheeler 2023-01-10 17:16:39 -05:00
parent 49dd239f53
commit c3d164cc2c
3 changed files with 141 additions and 53 deletions

View file

@ -75,6 +75,10 @@ const endpoints = {
url: "/experiments/api/v1/experiments/run", url: "/experiments/api/v1/experiments/run",
method: "POST", method: "POST",
}, },
ValidateZip: {
url: "/location/api/v1/location/zip",
method: "GET",
},
}; };
export { endpoints }; export { endpoints };

View file

@ -111,7 +111,7 @@ defineRule(
export default { export default {
name: "address-lookup", name: "address-lookup",
//mixins: [vinPagesMixin], mixins: [vinPagesMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
@ -135,16 +135,16 @@ export default {
return { return {
customerQuestions: { customerQuestions: {
addressQuestions: { addressQuestions: {
streetAddress: this.getRegistrationAddressFromStore(), streetAddress: this.registrationAddress,
city: this.getRegistrationCityFromStore(), city: this.registrationCity,
state: this.getRegistrationStateFromStore(), state: this.registrationState,
zipCode: this.getRegistrationZipFromStore(), zipCode: this.registrationZip,
}, },
firstName: this.getRegistrationFirstNameFromStore(), firstName: this.registrationFirstName,
lastName: this.getRegistrationLastNameFromStore(), lastName: this.registrationLastName,
emailAddress: this.getEmailFromStore(), emailAddress: this.getEmailFromStore,
}, },
serviceZipCode: this.getServiceZipFromStore(), serviceZipCode: this.serviceZip,
displayNonServiceableZipAlert: false, displayNonServiceableZipAlert: false,
displayVinNotFoundAlert: false, displayVinNotFoundAlert: false,
displayMatchedDifferentVehicleAlert: false, displayMatchedDifferentVehicleAlert: false,
@ -154,13 +154,39 @@ export default {
isSelectedGlassAvailableForVehicle: true, isSelectedGlassAvailableForVehicle: true,
customAlertData: {}, customAlertData: {},
displayInvalidZipAlert: false, displayInvalidZipAlert: false,
showServiceZipField: this.getServiceZipFromStore(), showServiceZipField: this.serviceZip,
isZipServiceable: false, isZipServiceable: false,
}; };
}, },
computed: {
registrationAddress() {
return this.mainStore.order.vehicle.registration.address;
},
registrationCity() {
return this.mainStore.order.vehicle.registration.city;
},
registrationState() {
return this.mainStore.order.vehicle.registration.state;
},
registrationZip() {
return this.mainStore.order.vehicle.registration.zipCode;
},
registrationFirstName() {
return this.mainStore.order.vehicle.registration.firstName;
},
registrationLastName() {
return this.mainStore.order.vehicle.registration.lastName;
},
getEmailFromStore() {
return this.mainStore.order.customer.emailAddress;
},
serviceZip() {
return this.mainStore.order.serviceLocation.zipCode;
}
},
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return this.mainStore.order.vehicle.carId !== null; return useMainStore().order.vehicle.carId !== null;
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
@ -176,30 +202,7 @@ export default {
); );
}); });
}, },
getRegistrationAddressFromStore() {
return useMainStore().order.vehicle.registration.address;
},
getRegistrationCityFromStore() {
return useMainStore().order.vehicle.registration.city;
},
getRegistrationStateFromStore() {
return useMainStore().order.vehicle.registration.state;
},
getRegistrationZipFromStore() {
return useMainStore().order.vehicle.registration.zipCode;
},
getRegistrationFirstNameFromStore() {
return useMainStore().order.vehicle.registration.firstName;
},
getRegistrationLastNameFromStore() {
return useMainStore().order.vehicle.registration.lastName;
},
getEmailFromStore() {
return useMainStore().order.customer.emailAddress;
},
getServiceZipFromStore() {
return useMainStore().order.serviceLocation.zipCode;
},
async forwardButtonAction() { async forwardButtonAction() {
this.resetWarningsAndErrors(); this.resetWarningsAndErrors();
@ -229,12 +232,8 @@ export default {
{ {
resultKey: "serviceZipValidationResponse", resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode promise: this.serviceZipCode
? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, { ? useMainStore().validateZip({zip: this.serviceZipCode})
zip: this.serviceZipCode, : useMainStore().validateZip({zip: this.customerQuestions.addressQuestions.zipCode})
})
: this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
zip: this.customerQuestions.addressQuestions.zipCode,
}),
}, },
]; ];
@ -314,8 +313,7 @@ export default {
} }
// Save vehicle, customer, service and registration information // Save vehicle, customer, service and registration information
await this.dispatchStoreAction( await useMainStore().saveRegistrationAddressLookup(
storeActions.SAVE_REGISTRATION_ADDRESS_LOOKUP,
{ {
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: vehicleInfo:
@ -334,13 +332,7 @@ export default {
false false
); );
await this.dispatchStoreAction( await useMainStore().saveServiceLocation(
storeActions.SAVE_EMAIL,
this.customerQuestions.emailAddress,
false
);
await this.dispatchStoreAction(
storeActions.SAVE_SERVICE_LOCATION,
{ {
address: this.customerQuestions.addressQuestions.streetAddress, address: this.customerQuestions.addressQuestions.streetAddress,
city: this.customerQuestions.addressQuestions.city, city: this.customerQuestions.addressQuestions.city,
@ -416,7 +408,7 @@ export default {
}, },
AlertMatchedDifferentVehicleBody() { AlertMatchedDifferentVehicleBody() {
const vinYmmFound = `${this.customAlertData?.vehicleInfo?.year} ${this.customAlertData?.vehicleInfo?.make} ${this.customAlertData?.vehicleInfo?.model}`; const vinYmmFound = `${this.customAlertData?.vehicleInfo?.year} ${this.customAlertData?.vehicleInfo?.make} ${this.customAlertData?.vehicleInfo?.model}`;
const vinYmmExpected = `${useMainStore().order.vehicle.year} ${useMainStore().order.vehicle.make} ${useMainStore().order.vehicle.model}`; const vinYmmExpected = `${this.mainStore.order.vehicle.year} ${this.mainStore.order.vehicle.make} ${this.mainStore.order.vehicle.model}`;
return this.getCmsContent("AlertMatchedDifferentVehicleWidget", "BodyText") return this.getCmsContent("AlertMatchedDifferentVehicleWidget", "BodyText")
.replaceAll("{custom:glassText}", getDamageString()) .replaceAll("{custom:glassText}", getDamageString())

View file

@ -49,10 +49,13 @@ const getDefaultState = () => {
city: null, city: null,
state: null, state: null,
zipCode: null, zipCode: null,
zipCodeCtu: null
}, },
lineItems: { lineItems: {
glassParts: null, glassParts: null,
otherParts: null otherParts: null,
supportingItems: null,
vaps: null
}, },
payment: { payment: {
isInsurance: true, isInsurance: true,
@ -358,7 +361,43 @@ export const useMainStore = defineStore({
this.updateNumberOfChips(isWindshieldRepair ? parseInt(selectedWindshieldChipCount) : null); this.updateNumberOfChips(isWindshieldRepair ? parseInt(selectedWindshieldChipCount) : null);
this.updateGlassToReplace(selectedGlassToReplace); this.updateGlassToReplace(selectedGlassToReplace);
} }
}, },
updateRegistration(registrationInfo) {
this.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
this.order.vehicle.registration.address = registrationInfo?.address;
this.order.vehicle.registration.city = registrationInfo?.city;
this.order.vehicle.registration.state = registrationInfo?.state;
this.order.vehicle.registration.zipCode = registrationInfo?.zipCode;
this.order.vehicle.registration.firstName = registrationInfo?.firstName;
this.order.vehicle.registration.lastName = registrationInfo?.lastName;
},
updateServiceLocation(serviceLocationInfo) {
this.order.serviceLocation.address = serviceLocationInfo.address;
this.order.serviceLocation.city = serviceLocationInfo.city;
this.order.serviceLocation.state = serviceLocationInfo.state;
this.order.serviceLocation.zipCode = serviceLocationInfo.zipCode;
this.order.serviceLocation.zipCodeCtu = serviceLocationInfo.zipCodeCtu;
},
resetRegistrationState() {
this.order.vehicle.registration.licensePlate = null;
this.order.vehicle.registration.address = null;
this.order.vehicle.registration.city = null;
this.order.vehicle.registration.state = null;
this.order.vehicle.registration.zipCode = null;
this.order.vehicle.registration.firstName = null;
this.order.vehicle.registration.lastName = null;
},
updateSupportingItems(partsData) {
this.order.lineItems.supportingItems = partsData;
},
updateVaps(partsData) {
this.order.lineItems.vaps = partsData;
},
updateVehicle(vehicle) { updateVehicle(vehicle) {
this.order.vehicle.carId = vehicle.carId; this.order.vehicle.carId = vehicle.carId;
@ -697,6 +736,59 @@ export const useMainStore = defineStore({
this.updateExperiments(response.data.experiments); this.updateExperiments(response.data.experiments);
}, },
async validateZip({ zip }) {
return await globalMethods.callHttpClient({
methods: endpoints.ValidateZip.method,
endpoint: `${endpoints.ValidateZip.url}/${zip}`,
});
},
saveServiceLocation(serviceLocationInfo) {
this.updateServiceLocation(serviceLocationInfo);
},
saveRegistrationAddressLookup({ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }) {
//Reset dependent state when changing
if
(
registrationInfo?.address !== this.order.vehicle.registration?.address ||
registrationInfo?.city !== this.order.vehicle.registration?.city ||
registrationInfo?.state !== this.order.vehicle.registration?.state ||
registrationInfo?.zipCode !== this.order.vehicle.registration?.zipCode ||
registrationInfo?.firstName !== this.order.vehicle.registration?.firstName ||
registrationInfo?.lastName !== this.order.vehicle.registration?.lastName
)
{
this.resetRegistrationAndDependencies();
if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageAndDependencies();
this.resetPartsAndDependencies();
}
//Save new values
this.updateVehicle(vehicleInfo);
this.updateRegistration(registrationInfo);
}
},
resetRegistrationAndDependencies() {
this.resetRegistrationState();
this.resetGlassPartsState();
this.updateSupportingItems(null);
},
resetDamageAndDependencies() {
this.resetDamageState();
this.resetGlassPartsState();
this.updateSupportingItems(null);
this.updateVaps(null);
},
resetPartsAndDependencies() {
this.resetGlassPartsState();
this.updateSupportingItems(null);
},
}, },
persist: true persist: true
}); });