setting up initial Pinia store state.
This commit is contained in:
parent
b125221e42
commit
2578223941
2 changed files with 79 additions and 58 deletions
|
|
@ -13,8 +13,11 @@ pinia.use(piniaPluginPersistedstate);
|
||||||
vueApp.use(pinia);
|
vueApp.use(pinia);
|
||||||
vueApp.config.globalProperties.$store = useMainStore();
|
vueApp.config.globalProperties.$store = useMainStore();
|
||||||
vueApp.mixin(baseMixin);
|
vueApp.mixin(baseMixin);
|
||||||
|
useMainStore().populateInitialState();
|
||||||
vueApp.use(router);
|
vueApp.use(router);
|
||||||
vueApp.mount("#app");
|
vueApp.mount("#app");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,66 +3,80 @@ import { endpoints } from "@/constants/endpoints.js";
|
||||||
import globalMethods from "@/global-methods";
|
import globalMethods from "@/global-methods";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
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({
|
export const useMainStore = defineStore({
|
||||||
id: 'main',
|
id: 'main',
|
||||||
state() {
|
state: () => state,
|
||||||
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
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getters: {},
|
getters: {},
|
||||||
actions:
|
actions:
|
||||||
{
|
{
|
||||||
|
|
@ -82,6 +96,10 @@ export const useMainStore = defineStore({
|
||||||
this.updateYear(year);
|
this.updateYear(year);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
populateInitialState()
|
||||||
|
{
|
||||||
|
Object.assign(this.$state, getDefaultState());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
persist: true
|
persist: true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue