<template>
    <div class="container-fluid shadow rounded-3 p-2 position-relative make-tall">
        <funnelHeader cmsWidgetName="FunnelHeaderWidget" ref="funnelHeader" />
        <h1>Reveal Confetti Page Placeholder</h1>
        <funnelFooter cmsWidgetName="FunnelFooterWidget" ref="funnelFooter" @back-clicked="backButtonAction" />
    </div>
</template>

<script>
// Components
import funnelHeader from "@/common-components/funnel-header/funnel-header";
import funnelFooter from "@/common-components/funnel-footer/funnel-footer";

// Supporting Files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper";
import {storeMutations} from "@/constants/store-mutations";
import {storeActions} from "@/constants/store-actions";
import store from "@/store";

export default {
    name: "quote",
    async beforeRouteEnter(to, from, next) {
        // Call APIs
        const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);

        // Settle promises and get results
        const promiseResultMap = [{
            resultKey: "cmsContent",
            promise: cmsContentPromise,
        }, ];

        const resultMap = await settleAllPromises(promiseResultMap);

        // Call the "next" function to complete the transition to this page.
        next((vm) => {
            vm.setCmsContent(resultMap.cmsContent);
        });
    },
    methods: {
        backButtonAction() {
            // route to move backwards
            this.$router.navigateWithoutSaving(
                this.navigationScenarios.CLICKED_BACK,
                this.$route
            );
        },
        arePagePrerequisitesValid() {
            return true;
        },
        resetDependentState() {
            // Set
            store.commit(storeMutations.UPDATE_GLASS_PARTS, null);
            // Invokes
            store.dispatch(storeActions.RESET_PARTS_AND_DEPS);
        },
    },
    data() {
    },
    components: {
        funnelHeader,
        funnelFooter,
    },
};
</script>
