CSR-347: refactor per PR comments

This commit is contained in:
Adam Caouette 2022-05-12 14:06:46 -04:00
parent 611b0c0730
commit 016e5c93af
4 changed files with 16 additions and 26 deletions

View file

@ -24,6 +24,7 @@ module.exports = {
"!src/layouts/address-lookup/customer-questions/customer-questions.vue", "!src/layouts/address-lookup/customer-questions/customer-questions.vue",
"!src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue", "!src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue",
"!src/layouts/address-vehicles/address-vehicles.vue", "!src/layouts/address-vehicles/address-vehicles.vue",
"!src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue",
"!src/common-components/dropdown-question/dropdown-question.vue", "!src/common-components/dropdown-question/dropdown-question.vue",
"!src/common-components/textbox-question/textbox-question.vue", "!src/common-components/textbox-question/textbox-question.vue",
"!src/helpers/validation-rules.js", "!src/helpers/validation-rules.js",

View file

@ -29,19 +29,12 @@ import { getDamageString } from "@/helpers/damage-helper";
export default { export default {
name: "address-vehicles-question", name: "address-vehicles-question",
data() {
return {
questionText: String,
customAlertData: {},
};
},
props: { props: {
vehicles: Array, vehicles: Array,
modelValue: String, modelValue: String,
cmsWidgetName: String, cmsWidgetName: String,
validationRules: String, validationRules: String,
isCarIdDifferent: Boolean, isCarIdDifferent: Boolean,
selectedVehicle: Object,
}, },
computed: { computed: {
differentVehicleAlertHeader() { differentVehicleAlertHeader() {
@ -66,6 +59,9 @@ export default {
this.selectedVehicle?.vehicle.model this.selectedVehicle?.vehicle.model
); );
}, },
questionText() {
return this.getCmsContent("VehicleConfirmationQuestion", "QuestionText");
},
selectedVehicleVin: { selectedVehicleVin: {
get: function() { get: function() {
return this.modelValue; return this.modelValue;
@ -74,10 +70,8 @@ export default {
this.$emit("update:modelValue", newValue); this.$emit("update:modelValue", newValue);
} }
}, },
}, selectedVehicle() {
methods: { return this.vehicles.find( ({ vin }) => vin === this.selectedVehicleVin[0] );
initializeComponent(VehicleConfirmationQuestion) {
this.questionText = VehicleConfirmationQuestion.QuestionText;
}, },
}, },
components: { components: {

View file

@ -24,7 +24,6 @@
:vehicles="VehiclesForQuestions" :vehicles="VehiclesForQuestions"
validationRules="vehicle-required" validationRules="vehicle-required"
v-model="selectedVehicleVin" v-model="selectedVehicleVin"
:selectedVehicle="selectedVehicle"
:isCarIdDifferent="isCarIdDifferent" :isCarIdDifferent="isCarIdDifferent"
/> />
<div class="alert-provide-vin my-5" v-if="splitAlertProvideVinBodyForLink.length"> <div class="alert-provide-vin my-5" v-if="splitAlertProvideVinBodyForLink.length">
@ -92,7 +91,6 @@ 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.$refs.addressVehiclesQuestion.initializeComponent(resultMap.cmsContent.VehicleConfirmationQuestion);
}); });
}, },
props: { props: {
@ -101,7 +99,6 @@ export default {
data() { data() {
return { return {
selectedVehicleVin: null, selectedVehicleVin: null,
selectedVehicle: {},
isCarIdDifferent: false, isCarIdDifferent: false,
isSelectedGlassAvailableForVehicle: true, isSelectedGlassAvailableForVehicle: true,
}; };
@ -122,7 +119,6 @@ export default {
return this.AlertProvideVinBody.split(/{(.*?)}/g); return this.AlertProvideVinBody.split(/{(.*?)}/g);
}, },
VehiclesForQuestions() { VehiclesForQuestions() {
const vehiclesData = this.VehiclesFromApi; const vehiclesData = this.VehiclesFromApi;
// Map API result data, to address-vehicles data structure // Map API result data, to address-vehicles data structure
@ -130,7 +126,6 @@ export default {
const maskSymbol = "X"; const maskSymbol = "X";
const vinStart = maskSymbol.repeat(v.vin.length-4); const vinStart = maskSymbol.repeat(v.vin.length-4);
const vinEnd = v.vin.substring(v.vin.length-4); const vinEnd = v.vin.substring(v.vin.length-4);
return { return {
vin: v.vin, vin: v.vin,
vehicle: v.vehicle, vehicle: v.vehicle,
@ -138,7 +133,6 @@ export default {
Name: v.vin, Name: v.vin,
SubText: "VIN " + vinStart + vinEnd, SubText: "VIN " + vinStart + vinEnd,
}; };
}); });
return mappedData; return mappedData;
@ -146,6 +140,9 @@ export default {
VehiclesFromApi() { VehiclesFromApi() {
return store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES); return store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES);
}, },
selectedVehicle() {
return this.VehiclesForQuestions.find( ({ vin }) => vin === this.selectedVehicleVin[0] );
},
}, },
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
@ -214,8 +211,6 @@ export default {
watch: { watch: {
selectedVehicleVin(vehicleVin) { selectedVehicleVin(vehicleVin) {
const selectedVin = vehicleVin[0];
this.selectedVehicle = this.VehiclesForQuestions.find( ({ vin }) => vin === selectedVin );
// does this vehicle match the previously selected carId? // does this vehicle match the previously selected carId?
this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId; this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId;
this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`); this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`);