Merge pull request #10 from Safelite/feature/Digital/SSR-47

Feature/digital/ssr 47
This commit is contained in:
Kulbhushan Kaushik 2022-10-06 13:28:59 -04:00 committed by GitHub
commit 0ec9fdccaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View file

@ -3,7 +3,7 @@
<input type="text" v-model="year"/> <input type="text" v-model="year"/>
<span> Vehicle Make Placeholder </span> <span> Vehicle Make Placeholder </span>
<span>{{returnVehicleYear}}</span> <span>{{returnVehicleYear}}</span>
<button @click="addYear(year)">Add</button> <button @click="updateVehicleYear(year)">Add</button>
</div> </div>
</template> </template>
@ -12,16 +12,16 @@
name: 'vehicle-make', name: 'vehicle-make',
methods: methods:
{ {
addYear(item) updateVehicleYear(item)
{ {
this.$store.saveVehicleYear(item); this.mainStore.updateVehicleYear(item);
} }
}, },
computed: computed:
{ {
returnVehicleYear() returnVehicleYear()
{ {
return this.$store.order.vehicle.year; return this.mainStore.order.vehicle.year;
} }
} }
} }

View file

@ -13,16 +13,15 @@ const vueApp = createApp(App);
const pinia = createPinia(); const pinia = createPinia();
pinia.use(piniaPluginPersistedstate); pinia.use(piniaPluginPersistedstate);
vueApp.use(pinia); vueApp.use(pinia);
vueApp.config.globalProperties.$store = useMainStore();
useMainStore().populateInitialState(); useMainStore().populateInitialState();
// Additional Vue items to setup // Additional Vue items to setup
vueApp.mixin(baseMixin); vueApp.mixin(baseMixin);
vueApp.use(router); vueApp.use(router);
vueApp.mount("#app"); vueApp.mount("#app");

View file

@ -3,6 +3,9 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar
import { vehicleCategories } from "@/constants/vehicle-categories.js"; import { vehicleCategories } from "@/constants/vehicle-categories.js";
import { queryStrings } from "@/constants/query-strings"; import { queryStrings } from "@/constants/query-strings";
import { dynamicStrings } from "@/constants/dynamic-strings"; import { dynamicStrings } from "@/constants/dynamic-strings";
import { useMainStore } from "../store";
import { mapStores } from "pinia";
export default { export default {
data() { data() {
@ -19,6 +22,8 @@ export default {
}, },
}, },
computed: { computed: {
// store will be accessible globally as its id + 'Store'
...mapStores(useMainStore),
storeActions() { storeActions() {
return storeActions; return storeActions;
}, },

View file

@ -48,10 +48,10 @@ export const useMainStore = defineStore({
actions: actions:
{ {
// Vehicle // Vehicle
saveVehicleYear(year) updateVehicleYear(year)
{ {
if (this.order.vehicle.year !== year) { if (this.order.vehicle.year !== year) {
this.updateYear(year); this.order.vehicle.year = year;
} }
}, },
populateInitialState() populateInitialState()
@ -63,4 +63,5 @@ export const useMainStore = defineStore({
}, },
persist: true persist: true
}); });