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 Object.keys(vehicleInfoToCommit).length === 0
? this.$store.getters.vehicle ? this.$store.getters.vehicle
: vehicleInfoToCommit, : vehicleInfoToCommit,
registrationInfo: { customerInfo: {
firstName: this.customerQuestions.firstName, firstName: this.customerQuestions.firstName,
lastName: this.customerQuestions.lastName, lastName: this.customerQuestions.lastName,
}, },

View file

@ -234,8 +234,6 @@ export const mutations = {
}, },
updateRegistration(state, registrationInfo) { updateRegistration(state, registrationInfo) {
state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate; state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
state.order.customer.firstName = registrationInfo?.firstName;
state.order.customer.lastName = registrationInfo?.lastName;
}, },
updateServiceZip(state, serviceZipInfo) { updateServiceZip(state, serviceZipInfo) {
state.order.serviceLocation.state = serviceZipInfo.state; state.order.serviceLocation.state = serviceZipInfo.state;
@ -1662,15 +1660,25 @@ export const actions = {
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
} }
//Save new values
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); 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( saveRegistrationAddressLookup(
context, context,
{ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo } { isSelectedGlassAvailableForVehicle, vehicleInfo, customerInfo }
) { ) {
//Reset dependent state when changing //Reset dependent state when changing
if (vehicleInfo.vin !== context.state.order.vehicle.vin) { 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_VEHICLE, vehicleInfo);
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 && customerInfo) {
context.commit(storeMutations.UPDATE_CUSTOMER_DETAILS, {
firstName: customerInfo.firstName,
lastName: customerInfo.lastName,
});
} }
}, },

View file

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