From 0e2f3ad480d23ca7632dafdcd14a26c9597f86c0 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Thu, 6 Oct 2022 08:11:21 -0400 Subject: [PATCH] commit --- src/layouts/vehicle-make/vehicle-make.vue | 8 ++++---- src/main.js | 3 +-- src/mixins/base-mixin.js | 5 +++++ src/store/index.js | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index 156d9162..b886840f 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -3,7 +3,7 @@ Vehicle Make Placeholder {{returnVehicleYear}} - + @@ -12,16 +12,16 @@ name: 'vehicle-make', methods: { - addYear(item) + updateVehicleYear(item) { - this.$store.saveVehicleYear(item); + this.mainStore.updateVehicleYear(item); } }, computed: { returnVehicleYear() { - return this.$store.order.vehicle.year; + return this.mainStore.order.vehicle.year; } } } diff --git a/src/main.js b/src/main.js index 93f11da2..2039c59a 100644 --- a/src/main.js +++ b/src/main.js @@ -13,16 +13,15 @@ const vueApp = createApp(App); const pinia = createPinia(); pinia.use(piniaPluginPersistedstate); vueApp.use(pinia); -vueApp.config.globalProperties.$store = useMainStore(); useMainStore().populateInitialState(); // Additional Vue items to setup vueApp.mixin(baseMixin); vueApp.use(router); - vueApp.mount("#app"); + diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 7e405d1b..b8f6115f 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -3,6 +3,9 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar import { vehicleCategories } from "@/constants/vehicle-categories.js"; import { queryStrings } from "@/constants/query-strings"; import { dynamicStrings } from "@/constants/dynamic-strings"; +import { useMainStore } from "../store"; +import { mapStores } from "pinia"; + export default { data() { @@ -19,6 +22,8 @@ export default { }, }, computed: { + // store will be accessible globally as its id + 'Store' + ...mapStores(useMainStore), storeActions() { return storeActions; }, diff --git a/src/store/index.js b/src/store/index.js index 6d8a16ed..c78651c0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -48,10 +48,10 @@ export const useMainStore = defineStore({ actions: { // Vehicle - saveVehicleYear(year) + updateVehicleYear(year) { if (this.order.vehicle.year !== year) { - this.updateYear(year); + this.order.vehicle.year = year; } }, populateInitialState() @@ -63,4 +63,5 @@ export const useMainStore = defineStore({ }, persist: true }); + \ No newline at end of file