Added Promise.All
This commit is contained in:
parent
b0257ecd46
commit
d3d880b2b3
3 changed files with 35 additions and 33 deletions
|
|
@ -2,7 +2,7 @@ import { storeActions } from "@/constants/store-actions.js";
|
|||
import { widgetNames } from "@/constants/widget-names.js";
|
||||
import store from "@/store";
|
||||
|
||||
export function GetContentFromCms(fmgPage) {
|
||||
export function fetchCmsContentForPage(fmgPage) {
|
||||
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
||||
|
||||
const pageDataFromCms = {
|
||||
|
|
@ -18,7 +18,6 @@ export function GetContentFromCms(fmgPage) {
|
|||
}
|
||||
|
||||
pageDataFromCms[widget.Type] = [widget.Model];
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1,40 +1,46 @@
|
|||
<template>
|
||||
<div class="select-car">
|
||||
<div class="select-car">
|
||||
<div class="select-car-form rounded text-center">
|
||||
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
||||
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" />
|
||||
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
||||
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
||||
import pageHeader from "@/ux-components/header/header";
|
||||
import {
|
||||
GetContentFromCms
|
||||
} from "@/helpers/cms-adapter";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import store from "@/store";
|
||||
import { storeActions } from "@/constants/store-actions.js";
|
||||
|
||||
export default {
|
||||
name: "vehicle-year",
|
||||
data() {
|
||||
return {
|
||||
pageHeaderWidgets: {},
|
||||
radioQuestionWidgets: {},
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
GetContentFromCms(to.query.fmgPage).then((response) => {
|
||||
console.log(response)
|
||||
next(vm => {
|
||||
vm.pageHeaderWidgets = response.PageHeaderWidget[0];
|
||||
vm.radioQuestionWidgets = response.RadioQuestionWidget[0];
|
||||
});
|
||||
});
|
||||
},
|
||||
components: {
|
||||
yearQuestion,
|
||||
pageHeader,
|
||||
},
|
||||
name: "vehicle-year",
|
||||
data() {
|
||||
return {
|
||||
pageHeaderWidgets: {},
|
||||
radioQuestionWidgets: {},
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
|
||||
Promise.allSettled([
|
||||
fetchCmsContentForPage(to.query.fmgPage),
|
||||
store.dispatch(storeActions.GET_VEHICLE_YEARS, {}),
|
||||
]).then(([contentPromise, getYearsPromise]) => {
|
||||
|
||||
|
||||
// Call our next function to transition to the next page.
|
||||
next((vm) => {
|
||||
vm.pageHeaderWidgets = contentPromise.value.PageHeaderWidget[0];
|
||||
vm.radioQuestionWidgets = contentPromise.value.RadioQuestionWidget[0];
|
||||
});
|
||||
});
|
||||
},
|
||||
components: {
|
||||
yearQuestion,
|
||||
pageHeader,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ export default {
|
|||
};
|
||||
},
|
||||
created() {
|
||||
this.dispatchNonBlockingStoreAction(this.storeActions.GET_VEHICLE_YEARS, {}).then((response) => {
|
||||
this.years = response.data;
|
||||
});
|
||||
},
|
||||
components: {
|
||||
radioQuestion,
|
||||
|
|
|
|||
Loading…
Reference in a new issue