This commit is contained in:
Kulbhushan Kaushik 2022-11-29 10:34:13 -05:00
parent 5eb4c2f9ee
commit ef9c7af480
4 changed files with 30 additions and 31 deletions

View file

@ -35,6 +35,10 @@ const endpoints = {
url: "/parts/api/v1/parts/parts",
method: "POST",
},
GetCapabilityQuestions: {
url: "/parts/api/v1/parts/capability-questions",
method: "GET",
},
GetVehicle: {
url: "/vehicle/api/v1/vehicle/lookup",
method: "GET",

View file

@ -24,6 +24,9 @@ export default {
const footerInfoBox = document.querySelector(".footer#infoBox");
return footerInfoBox ? footerInfoBox.offsetHeight : 0;
},
savePageDataToStore(page, data) {
useMainStore().updatePageData({ page: page, data: data});
},
},
computed: {
// store will be accessible globally as its id + 'Store'

View file

@ -1,10 +1,6 @@
import { issPageValues } from "@/router/router-constants/issPage-values";
import { storeMutations } from "@/constants/store-mutations.js";
import { navigationScenarios } from "../router/router-constants/navigation-scenarios";
import { storeActions } from "@/constants/store-actions";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import baseMixin from "@/mixins/base-mixin.js";
import store from "@/store";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
import { useMainStore } from "../store";
export default {
methods: {
@ -356,9 +352,9 @@ export default {
}
}
},
// TODO KO Delete `shouldGoToHeritageQuote`
// Can't use `this` because navigateForward is also called from vin-pages-mixin
async navigateForward(partsOrQuestions, vm, shouldGoToHeritageQuote) {
async navigateForward(partsOrQuestions, vm) {
const self = vm ?? this;
const currentPage = self.$route.query.issPage;
@ -370,9 +366,7 @@ export default {
if (hasPartQuestions && this.currentPageComesBeforePage(currentPage, issPageValues.PART_QUESTIONS))
{
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
self.$route,
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS, self.$route,
{},
{},
{ partsOrQuestions: partsOrQuestions }
@ -394,7 +388,7 @@ export default {
) {
// if any childpart questions
// go to molding-questions page and pass the partsData
self.$router.navigateWithSaving(
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
self.$route,
{},
@ -412,13 +406,7 @@ export default {
for (let partOrQuestion of partsOrQuestions) {
if (this.hasCapabilityQuestions([partOrQuestion])) {
let capabilityQuestionsForGlassLocation = (
await baseMixin.methods.dispatchStoreAction(
storeActions.GET_CAPABILITY_QUESTIONS,
{
carId: store.getters.vehicle.carId,
partNumber: partOrQuestion.parts[0].partNumber,
}
)
await self.mainStore.getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)
).data;
capabilityQuestionsForGlassLocation.forEach((question) => {
@ -434,7 +422,7 @@ export default {
}
}
self.$router.navigateWithSaving(
self.$router.navigate(
self.navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
self.$route,
{},
@ -446,32 +434,30 @@ export default {
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
// save to store lineItems.glassParts
this.mainStore.updateGlassParts(collectedGlassParts);
self.mainStore.updateGlassParts(collectedGlassParts);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
self.$route
);
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,self.$route);
}
},
// Can't use `this` because navigateForward is also called from quote
navigateBack(vm) {
const self = vm ?? this;
const partsOrQuestions = (
self.$store.getters.pageData(issPageValues.CAPABILITY_QUESTIONS) ??
self.$store.getters.pageData(issPageValues.MOLDING_QUESTIONS) ??
self.$store.getters.pageData(issPageValues.VEHICLE_PARTS) ??
self.$store.getters.pageData(issPageValues.PART_QUESTIONS)
self.mainStore.pageData(issPageValues.CAPABILITY_QUESTIONS) ??
self.mainStore.pageData(issPageValues.MOLDING_QUESTIONS) ??
self.mainStore.pageData(issPageValues.VEHICLE_PARTS) ??
self.mainStore.pageData(issPageValues.PART_QUESTIONS)
)?.partsOrQuestions;
const hasPartQuestions = this.hasPartQuestions(partsOrQuestions);
const hasGlassLocationWithMultipleParts =
this.hasGlassLocationWithMultipleParts(partsOrQuestions);
const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions);
const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions);
let backNavigationScenario = self.$store.getters.vehicle.vin
let backNavigationScenario = self.mainStore.vehicle.vin
? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS
: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS;
const currentPage = self.$route.query.fmgPage;
const currentPage = self.$route.query.issPage;
if (
hasCapabilityQuestions &&
this.currentPageComesAfterPage(currentPage, issPageValues.CAPABILITY_QUESTIONS)

View file

@ -254,6 +254,12 @@ export const useMainStore = defineStore({
return response;
},
getCapabilityQuestions(carId, partNumber) {
return globalMethods.callHttpClient({
method: endpoints.GetCapabilityQuestions.method,
endpoint: `${endpoints.GetCapabilityQuestions.url}/${carId}/${partNumber}`,
});
},
setVehicle() {
return globalMethods