Merge branch 'develop' into feature/Digital/SSR-122
This commit is contained in:
commit
a801c8d624
3 changed files with 90 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();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { getDateForSavedSessionTimeout } from "@/helpers/session-helper";
|
||||||
import globalMethods from "@/global-methods";
|
import globalMethods from "@/global-methods";
|
||||||
import { experimentTriggers } from "@/constants/experiments";
|
import { experimentTriggers } from "@/constants/experiments";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||||
|
|
||||||
const storeId = 'main';
|
const storeId = 'main';
|
||||||
|
|
||||||
|
|
@ -41,7 +42,7 @@ const getDefaultState = () => {
|
||||||
},
|
},
|
||||||
lineItems: {
|
lineItems: {
|
||||||
glassParts: null,
|
glassParts: null,
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
serviceLocation: {
|
||||||
address: null,
|
address: null,
|
||||||
city: null,
|
city: null,
|
||||||
|
|
@ -231,6 +232,40 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
||||||
|
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||||
|
const isGlassToReplaceTheSame =
|
||||||
|
this.order.damage.glassToReplace?.length === selectedGlassToReplace.length &&
|
||||||
|
this.order.damage.glassToReplace
|
||||||
|
.slice()
|
||||||
|
.sort()
|
||||||
|
.every(
|
||||||
|
(obj, index) =>
|
||||||
|
obj.glassLocation === selectedGlassPassedInSorted[index].glassLocation &&
|
||||||
|
obj.glassName === selectedGlassPassedInSorted[index].glassName
|
||||||
|
);
|
||||||
|
const isWindshieldRepairTheSame =
|
||||||
|
isWindshieldRepair === this.order.damage.isRepair;
|
||||||
|
|
||||||
|
const isChipCountTheSame =
|
||||||
|
selectedWindshieldChipCount === this.order.damage.numberOfChips;
|
||||||
|
|
||||||
|
const isDamageChanging =
|
||||||
|
!isGlassToReplaceTheSame ||
|
||||||
|
!isWindshieldRepairTheSame ||
|
||||||
|
(isWindshieldRepair && !isChipCountTheSame);
|
||||||
|
|
||||||
|
if (isDamageChanging) {
|
||||||
|
//Reset dependent state when changing
|
||||||
|
this.resetGlassPartsState();
|
||||||
|
|
||||||
|
// Save new values
|
||||||
|
this.updateIsRepair(isWindshieldRepair);
|
||||||
|
this.updateNumberOfChips(isWindshieldRepair ? parseInt(selectedWindshieldChipCount) : null);
|
||||||
|
this.updateGlassToReplace(selectedGlassToReplace);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
updateVehicle(vehicle) {
|
updateVehicle(vehicle) {
|
||||||
this.order.vehicle.carId = vehicle.carId;
|
this.order.vehicle.carId = vehicle.carId;
|
||||||
this.order.vehicle.category = vehicle.category;
|
this.order.vehicle.category = vehicle.category;
|
||||||
|
|
@ -253,10 +288,28 @@ export const useMainStore = defineStore({
|
||||||
this.order.vehicle.imageColor = null;
|
this.order.vehicle.imageColor = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetGlassPartsState() {
|
||||||
|
this.order.lineItems.glassParts = null;
|
||||||
|
this.order.damage.partQuestionAnswers = null;
|
||||||
|
this.order.damage.moldingQuestionAnswers = null;
|
||||||
|
this.order.damage.capabilityQuestionAnswers = null;
|
||||||
|
this.applicationUser.pageData[issPageValues.PART_QUESTIONS] = null;
|
||||||
|
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) {
|
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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -267,6 +320,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;
|
||||||
|
|
@ -280,12 +334,14 @@ 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;
|
||||||
this.order.vehicle.model = model;
|
this.order.vehicle.model = model;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
updateVehicleStyle(style) {
|
updateVehicleStyle(style) {
|
||||||
if(this.order.vehicle.style != style)
|
if(this.order.vehicle.style != style)
|
||||||
|
|
@ -295,6 +351,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;
|
||||||
|
|
@ -302,6 +359,18 @@ export const useMainStore = defineStore({
|
||||||
this.order.vehicle.style = style;
|
this.order.vehicle.style = style;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateIsRepair(isRepair) {
|
||||||
|
this.order.damage.isRepair = isRepair;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateNumberOfChips(numberOfChips) {
|
||||||
|
this.order.damage.numberOfChips = numberOfChips;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateGlassToReplace(glassToReplace) {
|
||||||
|
this.order.damage.glassToReplace = glassToReplace;
|
||||||
|
},
|
||||||
|
|
||||||
addEventToBus (event) {
|
addEventToBus (event) {
|
||||||
this.applicationUser.eventBus.push(event);
|
this.applicationUser.eventBus.push(event);
|
||||||
|
|
|
||||||
|
|
@ -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