Updating method and action name and awaiting data before page change on vehicle style page

This commit is contained in:
Max 2022-01-13 11:56:04 -05:00
parent d160a09c3b
commit 80a4de2cc7
4 changed files with 9 additions and 8 deletions

View file

@ -5,7 +5,7 @@ const storeActions = {
GET_VEHICLE_MAKES: "getVehicleMakes", GET_VEHICLE_MAKES: "getVehicleMakes",
GET_VEHICLE_MODELS: "getVehicleModels", GET_VEHICLE_MODELS: "getVehicleModels",
GET_VEHICLE_STYLES: "getVehicleStyles", GET_VEHICLE_STYLES: "getVehicleStyles",
GET_VEHICLE: "getVehicle", SET_VEHICLE: "setVehicle",
GET_DAMAGE_OPTIONS: "getDamageOptions", GET_DAMAGE_OPTIONS: "getDamageOptions",
GET_EVOX_IMAGE: "getEvoxImage", GET_EVOX_IMAGE: "getEvoxImage",
LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms",

View file

@ -142,7 +142,7 @@ describe("vehicle-style.vue", () => {
}, },
actionList: [ actionList: [
{ {
actionName: storeActions.GET_VEHICLE, actionName: storeActions.SET_VEHICLE,
data: 'mockData' data: 'mockData'
} }
] ]
@ -151,7 +151,7 @@ describe("vehicle-style.vue", () => {
//Act //Act
vehicleStyle.beforeRouteEnter.call(wrapper.vm, { query: { fmgPage: "vehicle-style" } }, undefined, (c) => c(wrapper.vm)); vehicleStyle.beforeRouteEnter.call(wrapper.vm, { query: { fmgPage: "vehicle-style" } }, undefined, (c) => c(wrapper.vm));
wrapper.vm.selectVehicle(); wrapper.vm.setVehicle();
await nextTick(); await nextTick();
//Assert //Assert

View file

@ -68,16 +68,17 @@ export default {
// route to move backwards // route to move backwards
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
selectVehicle() { setVehicle() {
this.dispatchNonBlockingStoreAction(this.storeActions.GET_VEHICLE, {year: this.$store.getters.vehicle.year, make: this.$store.getters.vehicle.make, model: this.$store.getters.vehicle.model, style: this.$store.getters.vehicle.style}); return this.dispatchNonBlockingStoreAction(this.storeActions.SET_VEHICLE, {year: this.$store.getters.vehicle.year, make: this.$store.getters.vehicle.make, model: this.$store.getters.vehicle.model, style: this.$store.getters.vehicle.style});
} }
}, },
watch: { watch: {
selectedStyle(style) { selectedStyle(style) {
this.$store.commit(this.storeMutations.UPDATE_STYLE, style); this.$store.commit(this.storeMutations.UPDATE_STYLE, style);
this.selectVehicle(); this.setVehicle().then(() => {
this.$router.navigate(this.navigationScenarios.SELECTED_STYLE, this.$route); this.$router.navigate(this.navigationScenarios.SELECTED_STYLE, this.$route);
});
} }
}, },

View file

@ -129,7 +129,7 @@ export default createStore({
payload: {}, payload: {},
}); });
}, },
getVehicle(context, {year, make, model, style}) { setVehicle(context, {year, make, model, style}) {
return globalMethods.callHttpClient({ return globalMethods.callHttpClient({
methods: endpoints.GetVehicle.method, methods: endpoints.GetVehicle.method,
endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`, endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`,