commit
This commit is contained in:
parent
fafd744e13
commit
b08796fdf1
1 changed files with 59 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { endpoints } from "@/constants/endpoints.js";
|
||||||
import { getDateForSavedSessionTimeout } from "@/helpers/session-helper";
|
import { getDateForSavedSessionTimeout } from "@/helpers/session-helper";
|
||||||
import globalMethods from "@/global-methods";
|
import globalMethods from "@/global-methods";
|
||||||
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';
|
||||||
|
|
||||||
|
|
@ -220,6 +221,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;
|
||||||
|
|
@ -242,6 +277,17 @@ 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;
|
||||||
|
},
|
||||||
|
|
||||||
updateVehicleYear(year) {
|
updateVehicleYear(year) {
|
||||||
if(this.order.vehicle.year != year)
|
if(this.order.vehicle.year != year)
|
||||||
{
|
{
|
||||||
|
|
@ -275,6 +321,7 @@ export const useMainStore = defineStore({
|
||||||
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)
|
||||||
|
|
@ -291,6 +338,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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue