update damage to the store.
This commit is contained in:
parent
b08796fdf1
commit
7c21369f57
3 changed files with 34 additions and 12 deletions
|
|
@ -291,17 +291,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
await this.dispatchStoreAction(
|
await this.mainStore.saveVehicleDamage(this.isWindshieldRepair,
|
||||||
this.storeActions.SAVE_VEHICLE_DAMAGE,
|
this.selectedGlassToReplace(),
|
||||||
{
|
this.selectedWindshieldOptions.selectedWindshieldChipCount);
|
||||||
isWindshieldRepair: this.isWindshieldRepair,
|
|
||||||
selectedGlassToReplace: this.selectedGlassToReplace(),
|
|
||||||
selectedWindshieldChipCount:
|
|
||||||
this.selectedWindshieldOptions.selectedWindshieldChipCount,
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
return this.navigateForward();
|
return this.navigateForward();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ const getDefaultState = () => {
|
||||||
moldingQuestionAnswers: null,
|
moldingQuestionAnswers: null,
|
||||||
capabilityQuestionAnswers: null,
|
capabilityQuestionAnswers: null,
|
||||||
},
|
},
|
||||||
|
lineItems: {
|
||||||
|
glassParts: null,
|
||||||
|
},
|
||||||
referralNumber: null,
|
referralNumber: null,
|
||||||
referralDate: null,
|
referralDate: null,
|
||||||
accountNumber: 0,
|
accountNumber: 0,
|
||||||
|
|
@ -286,12 +289,19 @@ export const useMainStore = defineStore({
|
||||||
this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = null;
|
this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = null;
|
||||||
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null;
|
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null;
|
||||||
this.applicationUser.pageData[issPageValues.CAPABILITY_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) {
|
updateVehicleYear(year) {
|
||||||
if(this.order.vehicle.year != year)
|
if(this.order.vehicle.year != year)
|
||||||
{
|
{
|
||||||
this.resetVehicleState();
|
this.resetVehicleState();
|
||||||
|
this.resetDamageState();
|
||||||
this.order.vehicle.year = year;
|
this.order.vehicle.year = year;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -302,6 +312,7 @@ export const useMainStore = defineStore({
|
||||||
const year = this.order.vehicle.year;
|
const year = this.order.vehicle.year;
|
||||||
|
|
||||||
this.resetVehicleState();
|
this.resetVehicleState();
|
||||||
|
this.resetDamageState();
|
||||||
|
|
||||||
this.order.vehicle.year = year;
|
this.order.vehicle.year = year;
|
||||||
this.order.vehicle.make = make;
|
this.order.vehicle.make = make;
|
||||||
|
|
@ -315,6 +326,7 @@ export const useMainStore = defineStore({
|
||||||
const make = this.order.vehicle.make;
|
const make = this.order.vehicle.make;
|
||||||
|
|
||||||
this.resetVehicleState();
|
this.resetVehicleState();
|
||||||
|
this.resetDamageState();
|
||||||
|
|
||||||
this.order.vehicle.year = year;
|
this.order.vehicle.year = year;
|
||||||
this.order.vehicle.make = make;
|
this.order.vehicle.make = make;
|
||||||
|
|
@ -331,6 +343,7 @@ export const useMainStore = defineStore({
|
||||||
const model = this.order.vehicle.model;
|
const model = this.order.vehicle.model;
|
||||||
|
|
||||||
this.resetVehicleState();
|
this.resetVehicleState();
|
||||||
|
this.resetDamageState();
|
||||||
|
|
||||||
this.order.vehicle.year = year;
|
this.order.vehicle.year = year;
|
||||||
this.order.vehicle.make = make;
|
this.order.vehicle.make = make;
|
||||||
|
|
|
||||||
|
|
@ -140,4 +140,21 @@ describe("Store", () => {
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalled();
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue