DigitalConsumer.ISS/src/store/index.js
Kulbhushan Kaushik 7408912c2e commit
2022-09-30 08:13:51 -04:00

82 lines
No EOL
1.8 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,
},
},
referralNumber: null,
referralDate: null,
accountNumber: 0,
},
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()
{
const storeId = 'main';
if(!localStorage.getItem(storeId)) {
this.$state = state;
}
}
},
persist: true
});