update damage to the store.

This commit is contained in:
Kulbhushan Kaushik 2022-11-22 13:58:21 -05:00
parent b08796fdf1
commit 7c21369f57
3 changed files with 34 additions and 12 deletions

View file

@ -291,17 +291,9 @@ export default {
},
async forwardButtonAction() {
await this.dispatchStoreAction(
this.storeActions.SAVE_VEHICLE_DAMAGE,
{
isWindshieldRepair: this.isWindshieldRepair,
selectedGlassToReplace: this.selectedGlassToReplace(),
selectedWindshieldChipCount:
this.selectedWindshieldOptions.selectedWindshieldChipCount,
},
false
);
await this.mainStore.saveVehicleDamage(this.isWindshieldRepair,
this.selectedGlassToReplace(),
this.selectedWindshieldOptions.selectedWindshieldChipCount);
return this.navigateForward();
},

View file

@ -39,6 +39,9 @@ const getDefaultState = () => {
moldingQuestionAnswers: null,
capabilityQuestionAnswers: null,
},
lineItems: {
glassParts: null,
},
referralNumber: null,
referralDate: null,
accountNumber: 0,
@ -286,12 +289,19 @@ export const useMainStore = defineStore({
this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = null;
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null;
this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null;
},
},
resetDamageState() {
this.order.damage.isRepair = null;
this.order.damage.numberOfChips = null;
this.order.damage.glassToReplace = null;
},
updateVehicleYear(year) {
if(this.order.vehicle.year != year)
{
this.resetVehicleState();
this.resetDamageState();
this.order.vehicle.year = year;
}
},
@ -302,6 +312,7 @@ export const useMainStore = defineStore({
const year = this.order.vehicle.year;
this.resetVehicleState();
this.resetDamageState();
this.order.vehicle.year = year;
this.order.vehicle.make = make;
@ -315,6 +326,7 @@ export const useMainStore = defineStore({
const make = this.order.vehicle.make;
this.resetVehicleState();
this.resetDamageState();
this.order.vehicle.year = year;
this.order.vehicle.make = make;
@ -331,6 +343,7 @@ export const useMainStore = defineStore({
const model = this.order.vehicle.model;
this.resetVehicleState();
this.resetDamageState();
this.order.vehicle.year = year;
this.order.vehicle.make = make;

View file

@ -140,4 +140,21 @@ describe("Store", () => {
expect(globalMethods.callHttpClient).toHaveBeenCalled();
});
it("saveVehicleDamage, should update damage", () => {
// Arrange
store.order.damage = {
glassToReplace: [{ glassName: "Single", glassLocation: "Windshield" }],
};
// Act
store.saveVehicleDamage( false,
[{ glassName: "Rear", glassLocation: "quarter" }],
0);
// Assert
expect(store.order.damage.glassToReplace).toEqual([{ glassName: "Rear", glassLocation: "quarter" }]);
expect(store.order.damage.isRepair).toEqual(false);
expect(store.order.damage.numberOfChips).toEqual(null);
});
});