only save customer name on address lookup if it's not already in the store
This commit is contained in:
CarlNation 2023-09-13 10:38:32 -04:00
parent 5cc384fd20
commit ad4b53a4b7
2 changed files with 22 additions and 9 deletions

View file

@ -320,7 +320,7 @@ export default {
Object.keys(vehicleInfoToCommit).length === 0
? this.$store.getters.vehicle
: vehicleInfoToCommit,
registrationInfo: {
customerInfo: {
firstName: this.customerQuestions.firstName,
lastName: this.customerQuestions.lastName,
},

View file

@ -234,8 +234,6 @@ export const mutations = {
},
updateRegistration(state, registrationInfo) {
state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
state.order.customer.firstName = registrationInfo?.firstName;
state.order.customer.lastName = registrationInfo?.lastName;
},
updateServiceZip(state, serviceZipInfo) {
state.order.serviceLocation.state = serviceZipInfo.state;
@ -1662,15 +1660,25 @@ export const actions = {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
}
//Save new values
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
if (registrationInfo) {
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
// only update name information if there isn't a value in state already
if (!context.getters.order.customer.firstName) {
context.commit(storeMutations.UPDATE_CUSTOMER_DETAILS, {
firstName: registrationInfo.firstName,
lastName: registrationInfo.lastName,
});
}
}
}
},
saveRegistrationAddressLookup(
context,
{ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }
{ isSelectedGlassAvailableForVehicle, vehicleInfo, customerInfo }
) {
//Reset dependent state when changing
if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
@ -1681,9 +1689,14 @@ export const actions = {
}
}
if (registrationInfo) {
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
// only update name information if there isn't a value in state already
if (!context.getters.order.customer.firstName && customerInfo) {
context.commit(storeMutations.UPDATE_CUSTOMER_DETAILS, {
firstName: customerInfo.firstName,
lastName: customerInfo.lastName,
});
}
},