diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 531043cb4..89f05cda1 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -13,7 +13,7 @@ :key="answer.Name ? answer.Name : answer" @isCheckedChanged="handleCheckedChanged" :buttonID="answer.Name ? groupName + '-' + answer.Name : groupName + '-' + answer" - :value="answer.Name ? answer.Name : answer" + :value="getValues(answer)" :buttonLabel="answer.Text ? answer.Text : answer" :buttonLabelSubCopy="answer.SubText" :textPosition="textPosition" @@ -79,6 +79,7 @@ export default { modelValue: Array, validationRules: String, suppressError: Boolean, + useTextForValue: Boolean, }, computed: { getFieldSetClasses() { @@ -121,6 +122,12 @@ export default { }, }, methods: { + getValues(answer){ + if (this.useTextForValue){ + return answer.Text + } + return answer.Name ? answer.Name : answer; + }, handleCheckedChanged(val) { if(this.isMultiSelect && this.selectedValues) { // Add or remove item to array of data to emit diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 3f258a310..24e5120bd 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -43,6 +43,10 @@ const endpoints = { url: "/vehicle/api/v1/vehicle/Lookup", method: "POST", }, + GetPartsOrQuestions: { + url: "/parts/api/v1/parts/parts-or-questions", + method: "POST", + }, }; export { endpoints }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index c572c4f69..6ac9b6926 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -10,6 +10,9 @@ const storeMutations = { UPDATE_VEHICLE_IMAGE_URL: "updateVehicleImageUrl", UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber", UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor", + UPDATE_IS_REPAIR: "updateIsRepair", + UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips", + UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace", // EVENT BUS MUTATIONS ADD_EVENT_TO_BUS: "addEventToBus", diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index 978cf6b41..25eca62da 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -52,7 +52,7 @@ export default ({ }, updateSelectedValues() { // UPDATE SELECTEDVALUES IF ONLY ONE ANSWER - if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1 && this.selectedValues) { + if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) { this.selectedValues = [this.answersToDisplay[0].Name]; } }, diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index aa888e14a..cef8e076c 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -25,7 +25,7 @@ v-model="selectedRearReplaceOptions" groupName="BackGlassReplaceOptionsQuestion" /> - + @@ -41,6 +41,7 @@ import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/winds import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question"; // Supporting files +import { routerParameterKeys } from "@/router/router-constants/router-parameter-keys"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { storeActions } from "@/constants/store-actions"; @@ -102,14 +103,6 @@ export default { ); }); }, - computed: { - isRearWindowDamageLocation() { - return this.selectedDamageLocations.some(selectedDamages => - { - return selectedDamages.toUpperCase() === "REARWINDOW"; - }); - }, - }, data(){ return { selectedDamageLocations: [], @@ -137,7 +130,99 @@ export default { this.$route ); }, + async forwardButtonAction() { + var windshieldChipCount = this.selectedWindshieldOptions.selectedWindshieldChipCount && this.isWindshieldDamageLocation ? + this.selectedWindshieldOptions.selectedWindshieldChipCount[0] : null; + + this.$store.commit(this.storeMutations.UPDATE_IS_REPAIR, this.isWindshieldRepair); + + if (windshieldChipCount){ + this.$store.commit(this.storeMutations.UPDATE_NUMBER_OF_CHIPS, parseInt(windshieldChipCount)); + } + + this.$store.commit(this.storeMutations.UPDATE_GLASS_TO_REPLACE, this.selectedGlassToReplace()); + + const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS, + { carId: this.$store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false); + + this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_GLASS_MULTIPLE_PARTS, this.$route, { [routerParameterKeys.VEHICLE_PARTS_DATA]: partsData}); + }, + + selectedGlassToReplace() { + var selectedGlassToReplace = []; + if (this.isWindshieldDamageLocation && !this.isWindshieldRepair){ + this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(wsItem => { + selectedGlassToReplace.push({ location: "Windshield", name: wsItem}); + }) + } + + if (this.isDriverSideReplace){ + this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach(driverItem => { + selectedGlassToReplace.push({ location: "Driver", name: driverItem}); + }) + } + + if (this.isPassengerSideReplace){ + this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(passengerItem => { + selectedGlassToReplace.push({ location: "Passenger", name: passengerItem}); + }) + selectedGlassToReplace = Array.prototype.concat.apply([], [selectedGlassToReplace, this.sideDoorOptionsData.selectedDoorSides.selectedPassengerSideReplaceOptions]); + } + + if (this.isRearWindowDamageLocation) { + this.selectedRearReplaceOptions.forEach(rearItem => { + selectedGlassToReplace.push({ location: "Rear", name: rearItem}); + }) + } + + return selectedGlassToReplace; + }, }, + computed:{ + isWindshieldDamageLocation() { + return this.selectedDamageLocations.some(selectedDamages => + { + return selectedDamages.toUpperCase() === "WINDSHIELD"; + }); + }, + isSideDoorDamageLocation() { + return this.selectedDamageLocations.some(selectedDamages => + { + return selectedDamages.toUpperCase() === "SIDEDOOR"; + }); + }, + isRearWindowDamageLocation() { + return this.selectedDamageLocations.some(selectedDamages => + { + return selectedDamages.toUpperCase() === "REARWINDOW"; + }); + }, + isWindshieldRepair() { + if (!this.isWindshieldDamageLocation) return false; + + return this.selectedWindshieldOptions.selectedWindshieldDamageType.some(selectedDamageType => + { + return selectedDamageType.toUpperCase() === "REPAIR"; + }); + }, + isDriverSideReplace() { + if (!this.isSideDoorDamageLocation) return false; + + return this.sideDoorOptionsData.selectedDoorSides.some(selectedDriverSide => + { + return selectedDriverSide.toUpperCase() === "DRIVERSIDE"; + }); + }, + isPassengerSideReplace() { + if (!this.isSideDoorDamageLocation) return false; + + return this.sideDoorOptionsData.selectedDoorSides.some(selectedPassengerSide => + { + return selectedPassengerSide.toUpperCase() === "PASSENGERSIDE"; + }); + } + }, + components: { funnelHeader, funnelFooter, diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue index 347ee2fdf..3226d9656 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question.vue @@ -6,6 +6,7 @@ :answers="answersFromCms" :groupName="groupName" buttonType="listButtonHorizontal" + useTextForValue v-model="selectedChipCountValues" /> diff --git a/src/router/router-constants/fmgPage-values.js b/src/router/router-constants/fmgPage-values.js index 9b82cdf7e..a23ba7eb6 100644 --- a/src/router/router-constants/fmgPage-values.js +++ b/src/router/router-constants/fmgPage-values.js @@ -4,6 +4,8 @@ const fmgPageValues = { VEHICLE_MODEL: "vehicle-model", VEHICLE_STYLE: "vehicle-style", VEHICLE_DAMAGE: "vehicle-damage", + VEHICLE_PARTS: "vehicle-parts", + QUOTE : "quote", }; export { fmgPageValues }; diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 48e36996b..05c95a7d6 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -4,6 +4,8 @@ const navigationScenarios = { SELECTED_MAKE: "SELECTED_MAKE", SELECTED_STYLE: "SELECTED_STYLE", CLICKED_BACK: "CLICKED_BACK", + SELECTED_DAMAGE_WITH_SINGLE_PART: "SELECTED_DAMAGE_WITH_SINGLE_PART", + SELECTED_GLASS_MULTIPLE_PARTS: "SELECTED_GLASS_MULTIPLE_PARTS" }; export { navigationScenarios }; diff --git a/src/router/router-constants/router-parameter-keys.js b/src/router/router-constants/router-parameter-keys.js new file mode 100644 index 000000000..27f6a54b0 --- /dev/null +++ b/src/router/router-constants/router-parameter-keys.js @@ -0,0 +1,5 @@ +const routerParameterKeys = { + VEHICLE_PARTS_DATA: "vehiclePartsData", + }; + + export { routerParameterKeys }; \ No newline at end of file diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 88c47563c..c5018716c 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -57,6 +57,23 @@ const routingTable = [ scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, }, + { + scenario: navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, + destinationFmgPageValue: fmgPageValues.QUOTE, + }, + ], + }, + { + fmgPageValue: fmgPageValues.VEHICLE_DAMAGE, + maps: [ + { + scenario: navigationScenarios.CLICKED_BACK, + destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, + }, + { + scenario: navigationScenarios.SELECTED_GLASS_MULTIPLE_PARTS, + destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS, + }, ], }, ]; diff --git a/src/store/index.js b/src/store/index.js index 7feea102d..c46b0f1cf 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -66,6 +66,16 @@ export const mutations = { updateVehicleImageColor(state, imageColor) { state.order.vehicle.imageColor = imageColor; }, + updateIsRepair(state, isRepair){ + state.order.damage.isRepair = isRepair; + }, + updateNumberOfChips(state, numberOfChips){ + state.order.damage.numberOfChips = numberOfChips; + }, + updateGlassToReplace(state, glassToReplace){ + state.order.damage.glassToReplace = glassToReplace; + }, + // EVENT BUS MUTATIONS addEventToBus(state, event) { @@ -252,8 +262,8 @@ export const actions = { // Parts API Actions getPartsOrQuestions(context, { carId, glassArray, zipCode, vin = '' }) { return globalMethods.callHttpClient({ - method: endpoints.GetRouteInfo.method, - endpoint: endpoints.GetRouteInfo.url, + method: endpoints.GetPartsOrQuestions.method, + endpoint: endpoints.GetPartsOrQuestions.url, payload: { carId: carId, glass: glassArray,