Merge pull request #1340 from Safelite/feature/CSR-1564

CSR-1654
This commit is contained in:
CarlNation 2023-09-13 13:43:00 -04:00 committed by GitHub
commit e94bdba213
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 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,
});
}
},

View file

@ -1492,9 +1492,18 @@ describe("Actions", () => {
licensePlate: "ABC123",
},
},
customer: {
firstName: "test",
lastName: "test",
},
},
};
context.getters = {
...getters,
order: getters.order(context),
};
const commit = jest.fn();
const dispatch = jest.fn();
@ -1538,9 +1547,18 @@ describe("Actions", () => {
address: "123 Main St",
},
},
customer: {
firstName: "test",
lastName: "test",
},
},
};
context.getters = {
...getters,
order: getters.order(context),
};
const commit = jest.fn();
const dispatch = jest.fn();
@ -1552,7 +1570,7 @@ describe("Actions", () => {
isCarIdDifferent: true,
isSelectedGlassAvailableForVehicle: false,
vehicleInfo: { carId: "C010101", vin: "XXXXX" },
registrationInfo: { firstName: "abc", lastName: "123" },
customerInfo: { firstName: "abc", lastName: "123" },
serviceLocationInfo: { state: "CO" },
customerEmail: "test@safelite.com",
};
@ -1570,7 +1588,6 @@ describe("Actions", () => {
);
expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo);
expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo);
});
it("saveVehicle, should save vehicle info", () => {