import { storeActions } from "@/constants/store-actions.js";
import store from "@/store";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { saveSession } from "@/helpers/heritage-integration/order-helper.js";

export default {
    methods: {
        async navigateForwardWithSingleCarMatch() {
            // If we have not already saved a session, we need to save one now before the lengthy call to getPartsOrQuestions
            if (!store.getters.applicationUser.savedSessionId) {
                await saveSession({});
            }

            const result = await this.dispatchStoreAction(storeActions.GET_PARTS_OR_QUESTIONS);
            const partsOrQuestions = result.data.partsOrQuestions;

            vehicleQuestionsMixin.methods.navigateForward(partsOrQuestions, this);
        },
    },
};
