Put the store update methods back on the vehicle vue components.

This commit is contained in:
Jeremy Zimmerman 2022-11-11 12:01:25 -05:00
parent 7bc6458449
commit b019bd556e
6 changed files with 36 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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";

View file

@ -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);
},