From f266fce3f54e531e877562dd3ee87cdedf54e691 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 24 Aug 2022 10:56:31 -0400 Subject: [PATCH] CSR-111 WIP --- .../question-chain/question-chain.vue | 7 +- .../capability-questions.vue | 493 ++++++++++++++++-- src/mixins/vehicle-questions-mixin.js | 201 ++++++- src/store/index.js | 7 +- 4 files changed, 630 insertions(+), 78 deletions(-) diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index dee5d1f32..950c06e7e 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -1,5 +1,7 @@ diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 380805751..77ce21f23 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -68,42 +68,205 @@ export default { async navigateForward(partsOrQuestions, vm) { const self = vm ?? this; const currentPage = self.$route.query.fmgPage; - + const hasPartQuestions = this.hasPartQuestions(partsOrQuestions) const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(partsOrQuestions); const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions); - const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions); + + // TODO REMOVE + const hasCapabilityQuestions = true //this.hasCapabilityQuestions(partsOrQuestions); if (hasPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.PART_QUESTIONS)) { - self.$router.navigateWithSaving(self.navigationScenarios.HAS_PART_QUESTIONS, self.$route, {}, {}, {partsOrQuestions: partsOrQuestions}); + self.$router.navigateWithSaving(self.navigationScenarios.HAS_PART_QUESTIONS, self.$route, {}, {}, { partsOrQuestions: partsOrQuestions }); } else if (hasGlassLocationWithMultipleParts && this.currentPageComesBeforePage(currentPage, fmgPageValues.VEHICLE_PARTS)) { // if multiple parts on any glass // go to vehicle-parts page and pass the partsData - self.$router.navigateWithSaving(self.navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE,self.$route,{},{},{partsOrQuestions: partsOrQuestions}); + self.$router.navigateWithSaving(self.navigationScenarios.HAS_MULTIPLE_PARTS_TO_CHOOSE, self.$route, {}, {}, { partsOrQuestions: partsOrQuestions }); } else if (hasChildPartQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.MOLDING_QUESTIONS)) { // if any childpart questions // go to molding-questions page and pass the partsData - self.$router.navigateWithSaving(self.navigationScenarios.HAS_MOLDING_QUESTIONS,self.$route,{},{},{partsOrQuestions: partsOrQuestions}); + self.$router.navigateWithSaving(self.navigationScenarios.HAS_MOLDING_QUESTIONS, self.$route, {}, {}, { partsOrQuestions: partsOrQuestions }); } else if (hasCapabilityQuestions && this.currentPageComesBeforePage(currentPage, fmgPageValues.CAPABILITY_QUESTIONS)) { // if has capability questions // go to capability-questions page and pass the partsData - const windshieldPart = partsOrQuestions.filter(x => x.glassLocation === damageLocationsSelected.WINDSHIELD)[0].parts[0]; - let capabilityQuestions = (await baseMixin.methods.dispatchStoreAction(storeActions.GET_CAPABILITY_QUESTIONS, { - carId: store.getters.vehicle.carId, - partNumber: windshieldPart.partNumber - })).data; - capabilityQuestions.forEach(question => { - question.answers = question.answers.map(answer => { - return { - ...answer, - answerResult: answer.answerResult1 + partsOrQuestions = [ + { + "glassName": "Single", + "glassLocation": "Windshield", + "parts": [ + { + "partNumber": "A", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": true, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] + }, + ], + "partQuestions": null + }, + { + "glassName": "Front", + "glassLocation": "Driver", + "parts": [ + { + "partNumber": "B", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": true, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] + }, + ], + "partQuestions": null + }, + { + "glassName": "Rear", + "glassLocation": "Driver", + "parts": [ + + { + "partNumber": "C", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": false, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] + }, + ], + "partQuestions": null + } + ] + + partsOrQuestions = [ + { + "glassName": "Single", + "glassLocation": "Windshield", + "parts": [ + { + "partNumber": "A", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": true, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] } - }) - }); + ], + "partQuestions": null, + "capabilityQuestions": [ + { + "questionSequence": 1, + "questionText": "Is this the first question?", + "answers": [ + { + "answerResult1": "DYNAMIC", + "answerResult2": "1", + "answerText": "Yes", + "nextQuestionSequence": null, + "answerResult": "DYNAMIC" + }, + { + "answerResult1": "Unknown", + "answerResult2": "0", + "answerText": "No", + "nextQuestionSequence": null, + "answerResult": "Unknown" + } + ] + } + ] + }, + { + "glassName": "Front", + "glassLocation": "Driver", + "parts": [ + { + "partNumber": "B", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": true, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] + } + ], + "partQuestions": null, + "capabilityQuestions": [ + { + "questionSequence": 1, + "questionText": "Is this the second question?", + "answers": [ + { + "answerResult1": "Oh yeah", + "answerResult2": "1", + "answerText": "Yes", + "nextQuestionSequence": null, + "answerResult": "Oh yeah" + }, + { + "answerResult1": "Maybe", + "answerResult2": "0", + "answerText": "No", + "nextQuestionSequence": null, + "answerResult": "Maybe" + } + ] + } + ] + }, + { + "glassName": "Rear", + "glassLocation": "Driver", + "parts": [ + { + "partNumber": "C", + "description": "rain sensor, solar, 3rd visor band, soundproofing, high beam sensor", + "color": "Green Tint, Blue Shade", + "requiresRecalibration": true, + "requiresCapabilityQuestions": false, + "recalibrationType": null, + "childParts": null, + "childPartQuestions": [] + } + ], + "partQuestions": null + } + ] + + for (let partOrQuestion of partsOrQuestions) { + if (this.hasCapabilityQuestions([partOrQuestion])) { + let capabilityQuestionsForGlassLocation = (await baseMixin.methods.dispatchStoreAction(storeActions.GET_CAPABILITY_QUESTIONS, { + carId: "CR00064847", // store.getters.vehicle.carId, + partNumber: "DW01929GBYN" // glassLocationWithCapabilityQuestion.parts[0].partNumber + })).data; + + capabilityQuestionsForGlassLocation.forEach(question => { + question.answers = question.answers.map(answer => { + return { + ...answer, + answerResult: answer.answerResult1 + } + }) + }) + + partOrQuestion.capabilityQuestions = capabilityQuestionsForGlassLocation; + } + } + - self.$router.navigateWithSaving(self.navigationScenarios.HAS_CAPABILITY_QUESTIONS, self.$route, {}, {}, { partsOrQuestions, capabilityQuestions }); + + self.$router.navigateWithSaving(self.navigationScenarios.HAS_CAPABILITY_QUESTIONS, self.$route, {}, {}, { partsOrQuestions }); } else { // if single parts only const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); @@ -112,7 +275,7 @@ export default { self.$refs.loadingModal.showModal(); navigateToHeritageFunnel(); - + // For quote pages MVP release // self.$router.navigate(self.navigationScenarios.HAS_NO_MORE_QUESTIONS, self.$route); } diff --git a/src/store/index.js b/src/store/index.js index 359d9cb3b..62e0625cb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -749,18 +749,19 @@ export const actions = { }) }, - getPartFromCapabilityQuestionAnswer(context, selectedAnswerResult1) { + getPartFromCapabilityQuestionAnswer(context, glassLocation) { const pageData = context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS); - const part = pageData.partsOrQuestions.find(x => x.glassLocation === damageLocationsSelected.WINDSHIELD).parts[0]; + const part = pageData.partsOrQuestions.find(x => x.glassLocation === glassLocation).parts[0]; const capabilityQuestionAnswers = context.getters.damage.capabilityQuestionAnswers; + const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(x => x.glassLocation === glassLocation); return globalMethods.callHttpClient({ method: endpoints.ApplyCapabilityAnswerToPart.method, endpoint: endpoints.ApplyCapabilityAnswerToPart.url, payload: { part, - capabilityAnswerResults: capabilityQuestionAnswers + capabilityAnswerResults: capabilityQuestionAnswersForPart } }) },