diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index 5d29915e..2c9e2e76 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -91,7 +91,7 @@ }, watch: { selectedMake(make) { - this.mainStore.order.vehicle.make = make; + this.mainStore.updateVehicleMake(make); this.$router.navigate( this.navigationScenarios.SELECTED_MAKE, this.$route diff --git a/src/layouts/vehicle-model/vehicle-model.vue b/src/layouts/vehicle-model/vehicle-model.vue index 0377af02..f83b01c6 100644 --- a/src/layouts/vehicle-model/vehicle-model.vue +++ b/src/layouts/vehicle-model/vehicle-model.vue @@ -84,7 +84,7 @@ watch: { selectedModel(model) { - this.mainStore.order.vehicle.model = model; + this.mainStore.updateVehicleModel(model); this.$router.navigate( this.navigationScenarios.SELECTED_MODEL, this.$route diff --git a/src/layouts/vehicle-style/vehicle-style.vue b/src/layouts/vehicle-style/vehicle-style.vue index 76b70112..1bfbe9a7 100644 --- a/src/layouts/vehicle-style/vehicle-style.vue +++ b/src/layouts/vehicle-style/vehicle-style.vue @@ -78,7 +78,7 @@ export default { watch: { selectedStyle(style) { - this.mainStore.order.vehicle.style = style; + this.mainStore.updateVehicleStyle(style); this.$router.navigate( this.navigationScenarios.SELECTED_STYLE, this.$route diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index 9f556ba6..9036eb97 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -70,7 +70,7 @@ watch: { selectedYear(year) { const parsedYear = parseInt(year); - this.mainStore.order.vehicle.year = parsedYear; + this.mainStore.updateVehicleYear(parsedYear); this.$router.navigate( this.navigationScenarios.SELECTED_YEAR, this.$route diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 2608d526..8c280c03 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -1,6 +1,7 @@ + import { mapStores } from "pinia"; import { useMainStore } from "@/store"; - +; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { vehicleCategories } from "@/constants/vehicle-categories.js"; import { queryStrings } from "@/constants/query-strings"; diff --git a/src/store/index.js b/src/store/index.js index 72866728..8d7646e4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -188,7 +188,36 @@ export const useMainStore = defineStore({ endpoint: `${endpoints.GetVehicleStyles.url}/${this.order.vehicle.year}/${this.order.vehicle.make}/${this.order.vehicle.model}`, payload: {}, }); - }, + }, + + // Vehicle API Actions + updateVehicleYear(year) + { + if (this.order.vehicle.year !== year) { + this.order.vehicle.year = year; + } + }, + + updateVehicleMake(make) + { + if (this.order.vehicle.make !== make) { + this.order.vehicle.make = make; + } + }, + + updateVehicleModel(model) + { + if (this.order.vehicle.model !== model) { + this.order.vehicle.model = model; + } + }, + + updateVehicleStyle(style) + { + if (this.order.vehicle.style !== style) { + this.order.vehicle.style = style; + } + }, addEventToBus (event) { this.applicationUser.eventBus.push(event); },