839 lines
34 KiB
Vue
839 lines
34 KiB
Vue
<template>
|
|
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm">
|
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" ref="funnelHeader" />
|
|
<div class="container vehicle-damage">
|
|
<div class="row">
|
|
<div class="col-12 col-md-10 col-lg-8 col-xl-7">
|
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mb-4" />
|
|
<alert
|
|
ref="vehicleChangeAlert"
|
|
v-if="shouldDisplayVehicleChangeAlert"
|
|
class="mt-5 mb-0"
|
|
cmsWidgetName="VehicleChangeAlert"
|
|
alertClass="alert-warning"
|
|
:isDismissible="false" />
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<damageLocationQuestion
|
|
ref="damageLocation"
|
|
cmsWidgetName="DamageLocationQuestion"
|
|
v-model="selectedDamageLocations"
|
|
groupName="DamageLocationQuestion" />
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<windshieldOptions
|
|
class="windshield-options"
|
|
ref="windshieldOptions"
|
|
v-model="selectedWindshieldOptions"
|
|
:hasRepairReplaceConflict="hasRepairReplaceConflict"
|
|
:hasSplitSingleConflict="hasSplitSingleConflict"
|
|
:selectedDamageLocations="selectedDamageLocations" />
|
|
|
|
<alert
|
|
v-if="hasRepairReplaceConflict"
|
|
class="my-5"
|
|
cmsWidgetName="HasReplacementConflict"
|
|
alertClass="alert-danger"
|
|
:isDismissible="false" />
|
|
|
|
<sideDoorOptions
|
|
ref="sideDoorOptions"
|
|
cmsWidgetName="SideDoorSideQuestion"
|
|
groupName="SideDoorSideQuestion"
|
|
v-model="sideDoorOptionsData"
|
|
v-show="!hasRepairReplaceConflict"
|
|
:selectedDamageLocations="selectedDamageLocations" />
|
|
|
|
<replaceOptionsQuestion
|
|
ref="backGlassOptions"
|
|
cmsWidgetName="RearReplaceOptionsQuestion"
|
|
:isAvailable="isRearWindowDamageLocation && !hasRepairReplaceConflict"
|
|
v-model="selectedRearReplaceOptions"
|
|
groupName="BackGlassReplaceOptionsQuestion"
|
|
validationRules="replace-options-required" />
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<navbar
|
|
cmsWidgetName="FunnelFooterWidget"
|
|
:isForwardActionDisabled="!isContinueEnabled"
|
|
:isBackButtonHidden="shouldHideBackButton"
|
|
@back-clicked="backButtonAction"
|
|
@ForwardClicked="forwardButtonAction" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Form>
|
|
</template>
|
|
|
|
<script>
|
|
// Components
|
|
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
|
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
|
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
|
import sideDoorOptions from "@/layouts/vehicle-damage/side-door-options/side-door-options";
|
|
import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question";
|
|
import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options";
|
|
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
|
import alert from "@/ux-components/alert/alert";
|
|
|
|
// Supporting files
|
|
import { skipVinLookup } from "@/helpers/heritage-integration/navigation-helper";
|
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
|
import { storeActions } from "@/constants/store-actions";
|
|
import { Form, defineRule } from "vee-validate";
|
|
import { required } from "@/helpers/validation-rules";
|
|
import { errorMessages } from "@/constants/error-messages";
|
|
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
|
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
|
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
|
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
|
|
import { debugLog } from "@/helpers/debug-log-helper";
|
|
|
|
import store from "@/store";
|
|
import baseMixin from "@/mixins/base-mixin";
|
|
import { nextTick } from "vue";
|
|
import { getBoolFromString } from "@/helpers/boolean-helper";
|
|
import { externalParameterStatus } from "@/constants/external-parameters";
|
|
// DEFINE VALIDATION RULES
|
|
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
|
|
|
|
export default {
|
|
name: "vehicle-damage",
|
|
async beforeRouteEnter(to, from, next) {
|
|
// Call APIs
|
|
const cmsContentPromise = fetchCmsContentForPage(to.name);
|
|
|
|
const damageOptionsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
|
storeActions.GET_DAMAGE_OPTIONS,
|
|
{ carId: store.getters.vehicle.carId },
|
|
"vehicle-damage"
|
|
);
|
|
|
|
// Settle promises and get results
|
|
const promiseResultMap = [
|
|
{
|
|
resultKey: "cmsContent",
|
|
promise: cmsContentPromise,
|
|
},
|
|
{
|
|
resultKey: "damageOptions",
|
|
promise: damageOptionsPromise,
|
|
},
|
|
];
|
|
|
|
const resultMap = await settleAllPromises(promiseResultMap);
|
|
|
|
// Call the "next" function to complete the transition to this page.
|
|
next(async (vm) => {
|
|
vm.setCmsContent(resultMap.cmsContent);
|
|
vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions);
|
|
vm.$refs.sideDoorOptions.initializeComponent(
|
|
resultMap.damageOptions.driverSideOptions.availableReplacementOptions,
|
|
resultMap.damageOptions.passengerSideOptions.availableReplacementOptions
|
|
);
|
|
vm.$refs.windshieldOptions.initializeComponent(
|
|
resultMap.damageOptions.windshieldOptions.availableReplacementOptions
|
|
);
|
|
vm.$refs.backGlassOptions.initializeComponent(
|
|
resultMap.damageOptions.backGlassOptions.availableReplacementOptions
|
|
);
|
|
if (
|
|
store.getters.externalParameterState?.isExternalParameter &&
|
|
store.getters.externalParameterState?.isExternalParameter ===
|
|
externalParameterStatus.ACTIVE &&
|
|
store.getters.externalParameterState.vehicleDamage?.damageType
|
|
) {
|
|
await nextTick();
|
|
const isValid = await baseMixin.methods.isFormValid(vm.$refs.theForm);
|
|
debugLog(`**** vehicle-damage is form valid: ${isValid} ****`);
|
|
if (
|
|
store.getters.vehicle?.vehicleSubType === "MOTOR HOME" &&
|
|
store.getters.externalParameterDamage.damageType?.toUpperCase() ===
|
|
"WINDSHIELDREPLACE"
|
|
) {
|
|
return baseMixin.methods.ResetExternalParamsAndHideModal();
|
|
}
|
|
if (isValid) {
|
|
vm.forwardButtonAction();
|
|
} else {
|
|
if (store.getters.externalParameterCustomer?.phoneNumber) {
|
|
await baseMixin.methods.dispatchStoreAction(
|
|
storeActions.SAVE_PHONE_NUMBER,
|
|
store.getters.externalParameterCustomer.phoneNumber,
|
|
false
|
|
);
|
|
|
|
await baseMixin.methods.dispatchStoreAction(
|
|
storeActions.SAVE_IS_SMS_OPT_IN,
|
|
true,
|
|
false
|
|
);
|
|
}
|
|
|
|
if (store.getters.externalParameterServiceZip.zipCode) {
|
|
await baseMixin.methods.dispatchStoreAction(
|
|
storeActions.SAVE_SERVICE_ZIP_CODE_INFO,
|
|
{
|
|
zipCode: store.getters.externalParameterServiceZip.zipCode,
|
|
state: null,
|
|
zipCodeCtu: null,
|
|
providerNumber:
|
|
store.getters.externalParameterServiceZip.providerNumber,
|
|
},
|
|
false
|
|
);
|
|
}
|
|
|
|
const selectedGlassToReplace =
|
|
resultMap.damageOptions.windshieldOptions.availableReplacementOptions;
|
|
|
|
if (
|
|
selectedGlassToReplace == damageLocationsSelected.SINGLE &&
|
|
store.getters.externalParameterDamage.damageType
|
|
) {
|
|
vm.selectedWindshieldOptions.selectedWindshieldReplaceOptions.push(
|
|
damageLocationsSelected.SINGLE
|
|
);
|
|
if (
|
|
store.getters.externalParameterState.isExternalParameter &&
|
|
store.getters.externalParameterDamage.damageType !== "other"
|
|
) {
|
|
return vm.forwardButtonAction();
|
|
}
|
|
}
|
|
showFmgLoadingModal(false);
|
|
|
|
//clear any validation errors for external parameter flow
|
|
const form = vm.$refs.theForm;
|
|
if (form) {
|
|
form.setFieldError("DamageLocationQuestion", undefined);
|
|
form.setFieldTouched("DamageLocationQuestion", false, false);
|
|
}
|
|
}
|
|
} else {
|
|
showFmgLoadingModal(false);
|
|
}
|
|
});
|
|
},
|
|
data() {
|
|
return {
|
|
selectedDamageLocations: this.getDamageLocationsFromStore(),
|
|
sideDoorOptionsData: {
|
|
selectedDoorSides: this.getDoorSidesFromStore(),
|
|
selectedDriverSideReplaceOptions: this.getDriverSideReplaceOptionsFromStore(),
|
|
selectedPassengerSideReplaceOptions: this.getPassengerSideReplaceOptionsFromStore(),
|
|
},
|
|
selectedWindshieldOptions: this.getWindshieldOptionsFromStore(),
|
|
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
|
};
|
|
},
|
|
mounted() {
|
|
this.attachCustomEvents();
|
|
},
|
|
methods: {
|
|
clearChildEntries() {
|
|
if (!this.isSideDoorDamageLocation) {
|
|
this.sideDoorOptionsData = {
|
|
selectedDoorSides: [],
|
|
selectedDriverSideReplaceOptions: [],
|
|
selectedPassengerSideReplaceOptions: [],
|
|
};
|
|
} else {
|
|
if (!this.isDriverSideReplace) {
|
|
this.sideDoorOptionsData.selectedDriverSideReplaceOptions = [];
|
|
}
|
|
if (!this.isPassengerSideReplace) {
|
|
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions = [];
|
|
}
|
|
}
|
|
if (!this.isRearWindowDamageLocation) {
|
|
this.selectedRearReplaceOptions = "";
|
|
}
|
|
if (!this.isWindshieldDamageLocation) {
|
|
this.selectedWindshieldOptions = {
|
|
selectedWindshieldDamageType: "",
|
|
selectedWindshieldChipCount: null,
|
|
selectedWindshieldReplaceOptions: [],
|
|
};
|
|
} else {
|
|
if (!this.isWindshieldRepair) {
|
|
this.selectedWindshieldOptions.selectedWindshieldChipCount = null;
|
|
}
|
|
}
|
|
},
|
|
arePagePrerequisitesValid() {
|
|
if (store.getters.vehicle.carId) {
|
|
return true;
|
|
}
|
|
debugLog("**** Vehicle Page Prereq invalid ****");
|
|
debugLog("store.getters.vehicle.carId:", store.getters.vehicle?.carId, true);
|
|
return false;
|
|
},
|
|
attachCustomEvents() {
|
|
if (this.$store.getters.vehicle.imageVifNumber) {
|
|
this.pushEventToGA(
|
|
this.GaCategories.EVOX,
|
|
`${this.GaActions.VIF}_${this.$store.getters.vehicle.imageVifNumber}`,
|
|
this.$store.getters.vehicle.carId,
|
|
true
|
|
);
|
|
}
|
|
},
|
|
|
|
backButtonAction() {
|
|
// route to move backwards
|
|
this.$router.navigateWithoutSaving(
|
|
this.navigationScenarios.CLICKED_BACK,
|
|
this.pageName
|
|
);
|
|
},
|
|
|
|
getDamageLocationsFromStore() {
|
|
var glassSelections = [];
|
|
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return glass.glassLocation === damageLocationsSelected.WINDSHIELD;
|
|
}) ||
|
|
store.getters.damage.isRepair ||
|
|
store.getters.externalParameterDamage.isRepair ||
|
|
store.getters.externalParameterDamage.damageType
|
|
?.toUpperCase()
|
|
.includes("WINDSHIELD")
|
|
) {
|
|
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
|
}
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return (
|
|
glass.glassLocation === damageLocationsSelected.DRIVER ||
|
|
glass.glassLocation === damageLocationsSelected.PASSENGER
|
|
);
|
|
})
|
|
) {
|
|
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
|
}
|
|
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return glass.glassLocation === damageLocationsSelected.REAR;
|
|
})
|
|
) {
|
|
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
|
}
|
|
|
|
return glassSelections;
|
|
},
|
|
|
|
getWindshieldOptionsFromStore() {
|
|
var windShieldOptions = {
|
|
selectedWindshieldDamageType: "",
|
|
selectedWindshieldChipCount: null,
|
|
selectedWindshieldReplaceOptions: [],
|
|
};
|
|
|
|
if (
|
|
store.getters.externalParameterDamage.isRepair === undefined ||
|
|
store.getters.damage.isRepair === undefined
|
|
)
|
|
return windshieldOptions;
|
|
|
|
if (store.getters.externalParameterDamage.isRepair || store.getters.damage.isRepair) {
|
|
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
|
|
windShieldOptions.selectedWindshieldChipCount =
|
|
store.getters.externalParameterDamage.numberOfChips ||
|
|
store.getters.damage.numberOfChips;
|
|
} else {
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return (
|
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
|
glass.glassName === damageLocationsSelected.SINGLE
|
|
);
|
|
}) ||
|
|
store.getters.externalParameterDamage.damageType?.toUpperCase() ===
|
|
"WINDSHIELDREPLACE"
|
|
) {
|
|
windShieldOptions.selectedWindshieldDamageType =
|
|
damageLocationsSelected.REPLACE;
|
|
if (
|
|
!store.getters.externalParameterState.isExternalParameter ||
|
|
store.getters.externalParameterState?.isExternalParameter !==
|
|
externalParameterStatus.ACTIVE ||
|
|
!store.getters.externalParameterState.vehicleDamage?.damageType
|
|
) {
|
|
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
|
damageLocationsSelected.SINGLE
|
|
);
|
|
}
|
|
}
|
|
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return (
|
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
|
glass.glassName === damageLocationsSelected.DRIVER
|
|
);
|
|
})
|
|
) {
|
|
windShieldOptions.selectedWindshieldDamageType =
|
|
damageLocationsSelected.REPLACE;
|
|
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
|
damageLocationsSelected.DRIVER
|
|
);
|
|
}
|
|
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return (
|
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
|
glass.glassName === damageLocationsSelected.PASSENGER
|
|
);
|
|
})
|
|
) {
|
|
windShieldOptions.selectedWindshieldDamageType =
|
|
damageLocationsSelected.REPLACE;
|
|
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
|
damageLocationsSelected.PASSENGER
|
|
);
|
|
}
|
|
}
|
|
|
|
return windShieldOptions;
|
|
},
|
|
|
|
getDoorSidesFromStore() {
|
|
var doorSides = [];
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return glass.glassLocation === damageLocationsSelected.DRIVER;
|
|
})
|
|
) {
|
|
doorSides.push(damageLocationsSelected.DRIVERSIDE);
|
|
}
|
|
|
|
if (
|
|
store.getters.damage.glassToReplace?.some((glass) => {
|
|
return glass.glassLocation === damageLocationsSelected.PASSENGER;
|
|
})
|
|
) {
|
|
doorSides.push(damageLocationsSelected.PASSENGERSIDE);
|
|
}
|
|
|
|
return doorSides;
|
|
},
|
|
|
|
getDriverSideReplaceOptionsFromStore() {
|
|
var driverSideReplaceOptions = [];
|
|
|
|
store.getters.damage.glassToReplace?.forEach((glass) => {
|
|
if (glass.glassLocation === damageLocationsSelected.DRIVER) {
|
|
driverSideReplaceOptions.push(glass.glassName);
|
|
}
|
|
});
|
|
|
|
return driverSideReplaceOptions;
|
|
},
|
|
|
|
getPassengerSideReplaceOptionsFromStore() {
|
|
var passengerSideReplaceOptions = [];
|
|
|
|
store.getters.damage.glassToReplace?.forEach((glass) => {
|
|
if (glass.glassLocation === damageLocationsSelected.PASSENGER) {
|
|
passengerSideReplaceOptions.push(glass.glassName);
|
|
}
|
|
});
|
|
|
|
return passengerSideReplaceOptions;
|
|
},
|
|
|
|
getRearReplaceOptionsFromStore() {
|
|
var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(
|
|
(glass) => glass.glassLocation === damageLocationsSelected.REAR
|
|
)[0]?.glassName;
|
|
|
|
return rearReplaceOptions;
|
|
},
|
|
|
|
async forwardButtonAction() {
|
|
await this.dispatchStoreAction(
|
|
this.storeActions.SAVE_VEHICLE_DAMAGE,
|
|
{
|
|
isWindshieldRepair: this.isWindshieldRepair,
|
|
selectedGlassToReplace: this.selectedGlassToReplace(),
|
|
selectedWindshieldChipCount:
|
|
this.selectedWindshieldOptions.selectedWindshieldChipCount,
|
|
},
|
|
false
|
|
);
|
|
|
|
if (this.isWindshieldRepair) {
|
|
const supportingItems = await this.dispatchStoreActionWithLogging(
|
|
storeActions.GET_SUPPORTING_ITEMS,
|
|
null,
|
|
"vehicle-damage"
|
|
);
|
|
this.dispatchStoreAction(
|
|
this.storeActions.SAVE_SUPPORTING_ITEMS,
|
|
supportingItems.data,
|
|
false
|
|
);
|
|
}
|
|
|
|
return this.navigateForward();
|
|
},
|
|
|
|
async navigateForward() {
|
|
const payment = this.$store.getters.payment;
|
|
const policy = this.$store.getters.policy;
|
|
|
|
const vehicleChangedDuringPolicyLookupInHeritage =
|
|
payment.isInsurance &&
|
|
payment.insuranceCoverage.coverageStatus &&
|
|
payment.insuranceCoverage.coverageStatus !== "" &&
|
|
policy.policyNumber !== "";
|
|
|
|
const skipVin = await skipVinLookup();
|
|
|
|
this.pushEventToGA(
|
|
this.GaCategories.VIN_ELIGIBLE,
|
|
skipVin ? this.GaActions.FALSE : this.GaActions.TRUE,
|
|
this.$store.getters.vehicle.carId,
|
|
true
|
|
);
|
|
|
|
if (vehicleChangedDuringPolicyLookupInHeritage) {
|
|
if (skipVin) {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN,
|
|
this.pageName
|
|
);
|
|
} else {
|
|
if (store.getters.damage.isRepair) {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios
|
|
.CLICKED_FORWARD_WITH_REPAIR_AND_VERIFIED_INSURANCE,
|
|
this.pageName
|
|
);
|
|
} else {
|
|
if (store.getters.vehicle.vin) {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios
|
|
.CLICKED_FORWARD_WITH_REPLACE_AND_VERIFIED_INSURANCE,
|
|
this.pageName
|
|
);
|
|
} else {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
|
this.pageName
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// If vin already exists, navigate directly to vin-lookup
|
|
else if (store.getters.vehicle.vin) {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
|
this.pageName
|
|
);
|
|
} else if (skipVin) {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN,
|
|
this.pageName
|
|
);
|
|
} else {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
|
this.pageName
|
|
);
|
|
}
|
|
},
|
|
|
|
selectedGlassToReplace() {
|
|
const selectedGlassToReplace = [];
|
|
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) {
|
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(
|
|
(wsItem) => {
|
|
selectedGlassToReplace.push({
|
|
glassLocation: damageLocationsSelected.WINDSHIELD,
|
|
glassName: wsItem,
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
if (this.isDriverSideReplace) {
|
|
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach((driverItem) => {
|
|
selectedGlassToReplace.push({
|
|
glassLocation: damageLocationsSelected.DRIVER,
|
|
glassName: driverItem,
|
|
});
|
|
});
|
|
}
|
|
|
|
if (this.isPassengerSideReplace) {
|
|
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(
|
|
(passengerItem) => {
|
|
selectedGlassToReplace.push({
|
|
glassLocation: damageLocationsSelected.PASSENGER,
|
|
glassName: passengerItem,
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
if (this.isRearWindowDamageLocation) {
|
|
selectedGlassToReplace.push({
|
|
glassLocation: damageLocationsSelected.REAR,
|
|
glassName: this.selectedRearReplaceOptions,
|
|
});
|
|
}
|
|
|
|
return selectedGlassToReplace;
|
|
},
|
|
},
|
|
computed: {
|
|
isWindshieldDamageLocation() {
|
|
return this.selectedDamageLocations.some((selectedDamages) => {
|
|
return selectedDamages.toUpperCase() === damageLocationsCms.WINDSHIELD;
|
|
});
|
|
},
|
|
isSideDoorDamageLocation() {
|
|
return this.selectedDamageLocations.some((selectedDamages) => {
|
|
return selectedDamages.toUpperCase() === damageLocationsCms.SIDEDOOR;
|
|
});
|
|
},
|
|
isRearWindowDamageLocation() {
|
|
return this.selectedDamageLocations.some((selectedDamages) => {
|
|
return selectedDamages.toUpperCase() === damageLocationsCms.REARWINDOW;
|
|
});
|
|
},
|
|
isWindshieldRepair() {
|
|
return (
|
|
this.isWindshieldDamageLocation &&
|
|
this.selectedWindshieldOptions.selectedWindshieldDamageType ===
|
|
damageLocationsSelected.REPAIR
|
|
);
|
|
},
|
|
isDriverSideReplace() {
|
|
if (!this.isSideDoorDamageLocation) return false;
|
|
|
|
return this.sideDoorOptionsData.selectedDoorSides.some((selectedDriverSide) => {
|
|
return selectedDriverSide.toUpperCase() === damageLocationsCms.DRIVERSIDE;
|
|
});
|
|
},
|
|
isPassengerSideReplace() {
|
|
if (!this.isSideDoorDamageLocation) return false;
|
|
|
|
return this.sideDoorOptionsData.selectedDoorSides.some((selectedPassengerSide) => {
|
|
return selectedPassengerSide.toUpperCase() === damageLocationsCms.PASSENGERSIDE;
|
|
});
|
|
},
|
|
hasRepairReplaceConflict() {
|
|
return (
|
|
this.isWindshieldDamageLocation &&
|
|
this.selectedDamageLocations.length > 1 &&
|
|
this.isWindshieldRepair
|
|
);
|
|
},
|
|
hasSplitSingleConflict() {
|
|
if (
|
|
!this.selectedDamageLocations?.includes("Windshield") ||
|
|
this.selectedWindshieldOptions.selectedWindshieldDamageType ===
|
|
damageLocationsSelected.REPAIR ||
|
|
!this.selectedWindshieldOptions.selectedWindshieldReplaceOptions
|
|
)
|
|
return false;
|
|
|
|
return (
|
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
|
(selectedSingleWindshield) => {
|
|
return (
|
|
selectedSingleWindshield.toUpperCase() ===
|
|
damageLocationsSelected.SINGLE.toUpperCase()
|
|
);
|
|
}
|
|
) &&
|
|
(this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
|
(selectedDriverWindshield) => {
|
|
return (
|
|
selectedDriverWindshield.toUpperCase() ===
|
|
damageLocationsSelected.DRIVER.toUpperCase()
|
|
);
|
|
}
|
|
) ||
|
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
|
(selectedPassengerWindshield) => {
|
|
return (
|
|
selectedPassengerWindshield.toUpperCase() ===
|
|
damageLocationsSelected.PASSENGER.toUpperCase()
|
|
);
|
|
}
|
|
))
|
|
);
|
|
},
|
|
shouldDisplayVehicleChangeAlert() {
|
|
return getBoolFromString(this.$route?.query?.displayVehicleChangeAlert);
|
|
},
|
|
shouldHideBackButton() {
|
|
return this.$store.getters.requiresVerifiedRedirecting;
|
|
},
|
|
isContinueEnabled() {
|
|
var isEnabled =
|
|
this.isAnyDamageSelected &&
|
|
this.isWindshieldValid &&
|
|
this.isRearGlassValid &&
|
|
this.isSideGlassValid;
|
|
if (!isEnabled) {
|
|
debugLog(
|
|
`************************ isContinueEnabled: ${isEnabled} *****************************`
|
|
);
|
|
debugLog(`**** this.isAnyDamageSelected: ${this.isAnyDamageSelected} ****`);
|
|
debugLog(`**** this.isWindshieldValid: ${this.isWindshieldValid} ****`);
|
|
debugLog(`**** this.isRearGlassValid: ${this.isRearGlassValid} ****`);
|
|
debugLog(`**** this.isSideGlassValid: ${this.isSideGlassValid} ****`);
|
|
}
|
|
return isEnabled;
|
|
},
|
|
isAnyDamageSelected() {
|
|
return this.selectedDamageLocations != null && this.selectedDamageLocations.length != 0;
|
|
},
|
|
isSideGlassValid() {
|
|
if (this.isSideDoorDamageLocation) {
|
|
if (
|
|
this.sideDoorOptionsData.selectedDoorSides == null ||
|
|
this.sideDoorOptionsData.selectedDoorSides == 0
|
|
) {
|
|
// SideDoor is selected, but "which side" question is unanswered
|
|
return false;
|
|
} else {
|
|
if (this.isPassengerSideReplace) {
|
|
if (
|
|
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions == null ||
|
|
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.length == 0
|
|
) {
|
|
// PassengerSide is selected, but no sub option is
|
|
return false;
|
|
}
|
|
}
|
|
if (this.isDriverSideReplace) {
|
|
if (
|
|
this.sideDoorOptionsData.selectedDriverSideReplaceOptions == null ||
|
|
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.length == 0
|
|
) {
|
|
// DriverSide is selected, but no sub option is
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
isRearGlassValid() {
|
|
if (this.isRearWindowDamageLocation) {
|
|
if (!this.selectedRearReplaceOptions) {
|
|
// RearDoor is selected, but rear option question is unanswered
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
isWindshieldValid() {
|
|
if (this.isWindshieldDamageLocation) {
|
|
if (!this.selectedWindshieldOptions.selectedWindshieldDamageType) {
|
|
// Windshield is selected but no replace/repair option is selected
|
|
return false;
|
|
} else {
|
|
if (this.hasSplitSingleConflict) {
|
|
return false;
|
|
}
|
|
if (this.isWindshieldRepair) {
|
|
if (this.hasRepairReplaceConflict) {
|
|
return false;
|
|
}
|
|
if (!this.selectedWindshieldOptions.selectedWindshieldChipCount) {
|
|
// Repair selected but no chips selected
|
|
return false;
|
|
}
|
|
} else {
|
|
if (
|
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions ==
|
|
null ||
|
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions
|
|
.length == 0
|
|
) {
|
|
// Replace selected but follow-up split/single question not answered
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
},
|
|
watch: {
|
|
selectedDamageLocations() {
|
|
this.clearChildEntries();
|
|
},
|
|
},
|
|
|
|
components: {
|
|
funnelHeader,
|
|
navbar,
|
|
funnelSubHeader,
|
|
sideDoorOptions,
|
|
damageLocationQuestion,
|
|
windshieldOptions,
|
|
replaceOptionsQuestion,
|
|
Form,
|
|
alert,
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.vehicle-damage {
|
|
.base-input-button:not(.has-error):hover.list-card:not(.selected) {
|
|
border-radius: 0.5rem;
|
|
}
|
|
.question-text {
|
|
margin: 1.5rem 0 0.5rem 0;
|
|
}
|
|
}
|
|
.replace-options-question {
|
|
.base-input-button:not(.has-error):hover.list-card:not(.selected) {
|
|
border-radius: 50rem;
|
|
}
|
|
.button-question {
|
|
label {
|
|
&.list-card,
|
|
&.list-card input[type="checkbox"]:checked + .list-card-content,
|
|
&.list-card input[type="radio"]:checked + .list-card-content {
|
|
border-radius: 50rem;
|
|
}
|
|
}
|
|
}
|
|
.question-text {
|
|
margin: 1.5rem 0 0.5rem 0;
|
|
@include media-breakpoint-up(md) {
|
|
margin: 1.5rem 0 0.5rem 0;
|
|
}
|
|
}
|
|
.two-list-card-width {
|
|
width: 100%;
|
|
flex: 0 auto;
|
|
margin-top: 0.5rem;
|
|
&:first-child {
|
|
margin-top: 1rem;
|
|
}
|
|
}
|
|
}
|
|
</style>
|