117 lines
3.3 KiB
Vue
117 lines
3.3 KiB
Vue
<template>
|
|
<div class="container-fluid shadow rounded-3 p-0 position-relative">
|
|
<funnelHeader ref="funnelHeader" />
|
|
<div class="select-car">
|
|
<div class="select-car-form rounded text-center">
|
|
<vehicleBanner ref="vehicleBanner" />
|
|
<funnelSubHeader
|
|
ref="funnelSubHeader"
|
|
:hasBackButton="true"
|
|
backButtonAccessibleText="Change Vehicle Model"
|
|
@click-event="backButtonAction"
|
|
/>
|
|
<styleQuestion v-model="selectedStyle" ref="styleQuestion" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
// Components
|
|
import styleQuestion from "@/layouts/vehicle-style/style-question/style-question";
|
|
import funnelHeader from "@/common-components/funnel-header/funnel-header";
|
|
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
|
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
|
// Supporting files
|
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
|
import store from "@/store";
|
|
|
|
export default {
|
|
name: "vehicle-style",
|
|
data() {
|
|
return {
|
|
selectedStyle: null,
|
|
};
|
|
},
|
|
computed: {},
|
|
|
|
async beforeRouteEnter(to, from, next) {
|
|
// Call APIs
|
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
|
const styleQuestionInitialDataPromise =
|
|
styleQuestion.methods.loadInitialData();
|
|
|
|
// Settle promises and get results
|
|
const promiseResultMap = [
|
|
{
|
|
resultKey: "cmsContent",
|
|
promise: cmsContentPromise,
|
|
},
|
|
{
|
|
resultKey: "styleQuestionInitialData",
|
|
promise: styleQuestionInitialDataPromise,
|
|
},
|
|
];
|
|
|
|
const resultMap = await settleAllPromises(promiseResultMap);
|
|
|
|
// Call the "next" function to complete the transition to this page.
|
|
next((vm) => {
|
|
vm.$refs.funnelSubHeader.initializeComponent(
|
|
resultMap.cmsContent.FunnelSubHeaderWidget
|
|
);
|
|
vm.$refs.funnelHeader.initializeComponent(
|
|
resultMap.cmsContent.FunnelHeaderWidget
|
|
);
|
|
vm.$refs.vehicleBanner.initializeComponent(
|
|
resultMap.cmsContent.VehicleBannerWidget
|
|
);
|
|
vm.$refs.styleQuestion.initializeComponent(
|
|
resultMap.cmsContent.VehicleStyleQuestion,
|
|
resultMap.styleQuestionInitialData
|
|
);
|
|
});
|
|
},
|
|
|
|
methods: {
|
|
backButtonAction() {
|
|
// route to move backwards
|
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
|
},
|
|
setVehicle() {
|
|
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,
|
|
}
|
|
);
|
|
},
|
|
arePagePrerequisitesValid() {
|
|
return store.getters.vehicle.model !== null;
|
|
},
|
|
},
|
|
|
|
watch: {
|
|
selectedStyle(style) {
|
|
this.$store.commit(this.storeMutations.UPDATE_STYLE, style);
|
|
this.setVehicle().then(() => {
|
|
this.$router.navigate(
|
|
this.navigationScenarios.SELECTED_STYLE,
|
|
this.$route
|
|
);
|
|
});
|
|
},
|
|
},
|
|
|
|
components: {
|
|
styleQuestion,
|
|
funnelHeader,
|
|
funnelSubHeader,
|
|
vehicleBanner,
|
|
},
|
|
};
|
|
</script>
|