CSR-111 Get capability questions

This commit is contained in:
Katie 2022-08-15 10:15:30 -04:00
parent db0c5de20f
commit 2fd175711a
8 changed files with 43 additions and 17 deletions

View file

@ -1,5 +1,7 @@
<template> <template>
<div v-for="(q, i) in questions" :key="i"> <div v-for="(q, i) in questions" :key="i">
{{ questions }}<br/>
{{q}}
<transition appear name="fade" mode="out-in"> <transition appear name="fade" mode="out-in">
<buttonQuestion <buttonQuestion
v-if="q.answerSelected || (q.questionSequence === currentQuestionNum)" v-if="q.answerSelected || (q.questionSequence === currentQuestionNum)"

View file

@ -59,6 +59,10 @@ const endpoints = {
url: "/parts/api/v1/parts/parts", url: "/parts/api/v1/parts/parts",
method: "POST", method: "POST",
}, },
GetCapabilityQuestions: {
url: "/parts/api/v1/parts/capability-questions",
method: "GET"
},
SaveOrder: { SaveOrder: {
url: "/order/api/v1/order/save", url: "/order/api/v1/order/save",
method: "POST", method: "POST",

View file

@ -21,6 +21,7 @@ const storeActions = {
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
GET_PARTS: "getParts", GET_PARTS: "getParts",
GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions",
SAVE_ORDER: "saveOrder", SAVE_ORDER: "saveOrder",
LOAD_ORDER: "loadOrder", LOAD_ORDER: "loadOrder",
UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE: "updateStoreWithSaveOrderResponse", UPDATE_STORE_WITH_SAVE_ORDER_RESPONSE: "updateStoreWithSaveOrderResponse",

View file

@ -20,13 +20,12 @@
:manualCopy="AlertFewMoreQuestionsCopy" :manualCopy="AlertFewMoreQuestionsCopy"
v-bind:isDismissible="false" v-bind:isDismissible="false"
/> />
<div v-for="(part, i) in capabilityQuestionsData" :key="i"> <div v-for="(question, i) in capabilityQuestionsData" :key="i">
<questionChain <questionChain
ref="questionChain" ref="questionChain"
v-model="selectedModel" v-model="selectedModel"
:questionData="part" :questionData="question"
:partIndex="i" :partIndex="i"
v-if="showThisPartQuestionChain(part, i)"
validationRules="questions-required" validationRules="questions-required"
/> />
</div> </div>
@ -71,6 +70,7 @@ export default {
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
const getCapabilityQuestions = store.dispatch(storeActions.GET_CAPABILITY_QUESTIONS, store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS));
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
@ -78,6 +78,10 @@ export default {
resultKey: "cmsContent", resultKey: "cmsContent",
promise: cmsContentPromise, promise: cmsContentPromise,
}, },
{
resultKey: "capabilityQuestions",
promise: getCapabilityQuestions,
},
]; ];
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
@ -85,20 +89,14 @@ export default {
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.capabilityQuestionsData = resultMap.capabilityQuestions;
console.log("CQ: ", resultMap.capabilityQuestions)
}); });
}, },
data() { data() {
return { return {
selectedModel: [], selectedModel: [],
partsQuestionsData: this.$store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS).partsOrQuestions.filter((p) => { capabilityQuestionsData: [],
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
return {
glassName: p.glassName,
glassLocation: p.glassLocation,
partQuestions: p.partQuestions,
};
}
}),
currentPartNum: 0, currentPartNum: 0,
}; };
}, },
@ -112,8 +110,8 @@ export default {
}, },
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return false; // TODO - DO TRUE TEST OF PAGEDATA const capabilityQuestionsPageData = store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS);
// return Object.keys(store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS)).length > 0; return capabilityQuestionsPageData && Object.keys(capabilityQuestionsPageData).length > 0;
}, },
showThisPartQuestionChain(part, i) { showThisPartQuestionChain(part, i) {
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
@ -129,6 +127,12 @@ export default {
}, },
async forwardButtonAction() { async forwardButtonAction() {
// TODO: TO COME // TODO: TO COME
// if questions are answered:
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD,
this.$route
);
}, },
}, },
watch: { watch: {

View file

@ -132,8 +132,8 @@ export default {
ColorAnswerText: p.color, ColorAnswerText: p.color,
FeatureAnswers: [ FeatureAnswers: [
{ {
FeatureAnswerText: p.description === "" ? p.color : p.description, FeatureAnswerText: p.description === "" ? p.color : p.description,
PartNumber: p.partNumber, PartNumber: p.partNumber,
}, },
], ],
}); });

View file

@ -2,6 +2,7 @@ import { storeActions } from "@/constants/store-actions.js";
import { storeMutations } from "@/constants/store-mutations.js"; import { storeMutations } from "@/constants/store-mutations.js";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin"; import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
import { damageLocationsSelected } from "@/constants/damage-locations-selected";
export default { export default {
mixins: [vehicleQuestionsMixin], mixins: [vehicleQuestionsMixin],
@ -26,7 +27,10 @@ export default {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS, this.$route, {}, {}, result.data); this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MOLDING_QUESTIONS, this.$route, {}, {}, result.data);
} }
else if (hasCapabilityQuestions) { else if (hasCapabilityQuestions) {
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS, this.$route, {}, {}, result.data); this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_CAPABILITY_QUESTIONS, this.$route, {}, {}, {
carId: this.$store.getters.vehicle.carId,
partNumber: result.data.partsOrQuestions.filter(x => x.glassLocation === damageLocationsSelected.WINDSHIELD)[0].parts[0].partNumber
});
} }
else { else {
// if single parts only // if single parts only

View file

@ -297,6 +297,10 @@ const routingTable = function(store) {
scenario: navigationScenarios.CLICKED_BACK, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
}, },
{
scenario: navigationScenarios.CLICKED_FORWARD,
destinationFmgPageValue: fmgPageValues.QUOTE
},
] ]
}, },
]; ];

View file

@ -722,6 +722,13 @@ export const actions = {
}); });
}, },
getCapabilityQuestions(context, { carId, partNumber }) {
return globalMethods.callHttpClient({
method: endpoints.GetCapabilityQuestions.method,
endpoint: `${endpoints.GetCapabilityQuestions.url}/${carId}/${partNumber}`,
})
},
// Order API Actions // Order API Actions
saveOrder(context) { saveOrder(context) {
const vehicle = context.getters.vehicle; const vehicle = context.getters.vehicle;