DigitalConsumer.ISS/src/store/index.js
Kulbhushan Kaushik 107dace02c commit
2022-09-27 15:14:56 -04:00

109 lines
No EOL
2.3 KiB
JavaScript

import { defineStore } from "pinia";
import { endpoints } from "@/constants/endpoints.js";
import globalMethods from "@/global-methods";
import { storeActions } from "@/constants/store-actions";
const getDefaultState = () => {
return {
order: {
vehicle: {
year: null,
make: null,
model: null,
style: null,
carId: null,
category: null,
vin: null,
imageUrl: null,
imageVifNumber: null,
imageColor: null,
registration: {
licensePlate: null,
address: null,
city: null,
state: null,
zipCode: null,
firstName: null,
lastName: null,
},
},
serviceLocation: {
address: null,
city: null,
state: null,
zipCode: null,
},
customer: {
emailAddress: null,
},
damage: {
isRepair: null,
numberOfChips: null,
glassToReplace: null,
partQuestionAnswers: null,
moldingQuestionAnswers: null,
capabilityQuestionAnswers: null
},
lineItems: {
glassParts: null
},
payment: {
isInsurance: null,
insuranceCoverage: {
isVerified: null
}
},
referralNumber: null,
referralDate: null,
referralCorrelationId: null,
accountNumber: 0,
eon: null
},
applicationUser: {
eventBus: [],
pageData: {},
saveOrderPromise: null,
savedSessionId: null,
crmCustomerId: null,
lastPageVisited: null,
experiments: [],
triggeredSiteEntry: false
},
};
};
export const state = getDefaultState();
export const useMainStore = defineStore({
id: 'main',
state: () => state,
getters: {},
actions:
{
updateYear(year) {
this.order.vehicle.year = year;
},
updateMake(make) {
this.order.vehicle.make = make;
},
updateModel(model) {
this.order.vehicle.model = model;
},
// Vehicle
saveVehicleYear(year)
{
if (this.order.vehicle.year !== year) {
this.updateYear(year);
}
},
populateInitialState()
{
if(!localStorage.getItem('main')) {
this.$state = state;
}
}
},
persist: true
});