commit
This commit is contained in:
parent
120369c5bc
commit
2ba1f71767
6 changed files with 61 additions and 54 deletions
|
|
@ -26,7 +26,11 @@ const endpoints = {
|
||||||
GetVehicleStyles: {
|
GetVehicleStyles: {
|
||||||
url: "/vehicle/api/v1/vehicle/styles",
|
url: "/vehicle/api/v1/vehicle/styles",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
|
GetDamageOptions: {
|
||||||
|
url: "/parts/api/v1/parts/damage-options",
|
||||||
|
method: "GET",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export { endpoints };
|
export { endpoints };
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@
|
||||||
<script>
|
<script>
|
||||||
import buttonQuestion from "@/common-components/button-question/button-question";
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
||||||
import { useMainStore } from '@/store';
|
|
||||||
import { defineRule } from "vee-validate";
|
import { defineRule } from "vee-validate";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
|
@ -133,7 +132,7 @@ export default {
|
||||||
const filteredAnswers = Array.isArray(this.answersFromCms)
|
const filteredAnswers = Array.isArray(this.answersFromCms)
|
||||||
? this.answersFromCms.filter((ans) => {
|
? this.answersFromCms.filter((ans) => {
|
||||||
const name = ans.Name.split("-");
|
const name = ans.Name.split("-");
|
||||||
return name[0].toUpperCase() === store.getters.vehicle.category;
|
return name[0].toUpperCase() === this.mainStore.getters.vehicle.category;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@
|
||||||
<site-footer
|
<site-footer
|
||||||
cmsWidgetName="SiteFooterWidget"
|
cmsWidgetName="SiteFooterWidget"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
:isBackButtonHidden="shouldHideBackButton"
|
|
||||||
@back-clicked="backButtonAction"
|
@back-clicked="backButtonAction"
|
||||||
@ForwardClicked="forwardButtonAction" />
|
@ForwardClicked="forwardButtonAction" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -71,15 +70,12 @@ import alert from "@/ux-components/alert/alert";
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
||||||
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
||||||
|
import { useMainStore } from '@/store';
|
||||||
import store from "@/store";
|
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
|
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
|
||||||
|
|
@ -88,11 +84,8 @@ export default {
|
||||||
name: "vehicle-damage",
|
name: "vehicle-damage",
|
||||||
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.issPage);
|
||||||
const damageOptionsPromise = baseMixin.methods.dispatchStoreAction(
|
const damageOptionsPromise = useMainStore().getDamageOptions(useMainStore().getters.vehicle.carId);
|
||||||
storeActions.GET_DAMAGE_OPTIONS,
|
|
||||||
{ carId: store.getters.vehicle.carId }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -136,46 +129,32 @@ export default {
|
||||||
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.attachCustomEvents();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
if (store.getters.vehicle.carId) {
|
if (this.mainStore.order.vehicle.carId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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() {
|
backButtonAction() {
|
||||||
// route to move backwards
|
// route to move backwards
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
|
|
||||||
getDamageLocationsFromStore() {
|
getDamageLocationsFromStore() {
|
||||||
var glassSelections = [];
|
var glassSelections = [];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return glass.glassLocation === damageLocationsSelected.WINDSHIELD;
|
return glass.glassLocation === damageLocationsSelected.WINDSHIELD;
|
||||||
}) ||
|
}) ||
|
||||||
store.getters.damage.isRepair
|
this.mainStore.getters.damage.isRepair
|
||||||
) {
|
) {
|
||||||
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return (
|
return (
|
||||||
glass.glassLocation === damageLocationsSelected.DRIVER ||
|
glass.glassLocation === damageLocationsSelected.DRIVER ||
|
||||||
glass.glassLocation === damageLocationsSelected.PASSENGER
|
glass.glassLocation === damageLocationsSelected.PASSENGER
|
||||||
|
|
@ -186,7 +165,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return glass.glassLocation === damageLocationsSelected.REAR;
|
return glass.glassLocation === damageLocationsSelected.REAR;
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
|
@ -203,14 +182,14 @@ export default {
|
||||||
selectedWindshieldReplaceOptions: [],
|
selectedWindshieldReplaceOptions: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (store.getters.damage.isRepair === undefined) return windshieldOptions;
|
if (this.mainStore.getters.damage.isRepair === undefined) return windshieldOptions;
|
||||||
|
|
||||||
if (store.getters.damage.isRepair) {
|
if (this.mainStore.getters.damage.isRepair) {
|
||||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
|
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
|
||||||
windShieldOptions.selectedWindshieldChipCount = store.getters.damage.numberOfChips;
|
windShieldOptions.selectedWindshieldChipCount = this.mainStore.getters.damage.numberOfChips;
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return (
|
return (
|
||||||
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||||
glass.glassName === damageLocationsSelected.SINGLE
|
glass.glassName === damageLocationsSelected.SINGLE
|
||||||
|
|
@ -225,7 +204,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return (
|
return (
|
||||||
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||||
glass.glassName === damageLocationsSelected.DRIVER
|
glass.glassName === damageLocationsSelected.DRIVER
|
||||||
|
|
@ -240,7 +219,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return (
|
return (
|
||||||
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||||
glass.glassName === damageLocationsSelected.PASSENGER
|
glass.glassName === damageLocationsSelected.PASSENGER
|
||||||
|
|
@ -261,7 +240,7 @@ export default {
|
||||||
getDoorSidesFromStore() {
|
getDoorSidesFromStore() {
|
||||||
var doorSides = [];
|
var doorSides = [];
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return glass.glassLocation === damageLocationsSelected.DRIVER;
|
return glass.glassLocation === damageLocationsSelected.DRIVER;
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
|
@ -269,7 +248,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
store.getters.damage.glassToReplace?.some((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
|
||||||
return glass.glassLocation === damageLocationsSelected.PASSENGER;
|
return glass.glassLocation === damageLocationsSelected.PASSENGER;
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
|
@ -282,7 +261,7 @@ export default {
|
||||||
getDriverSideReplaceOptionsFromStore() {
|
getDriverSideReplaceOptionsFromStore() {
|
||||||
var driverSideReplaceOptions = [];
|
var driverSideReplaceOptions = [];
|
||||||
|
|
||||||
store.getters.damage.glassToReplace?.forEach((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.forEach((glass) => {
|
||||||
if (glass.glassLocation === damageLocationsSelected.DRIVER) {
|
if (glass.glassLocation === damageLocationsSelected.DRIVER) {
|
||||||
driverSideReplaceOptions.push(glass.glassName);
|
driverSideReplaceOptions.push(glass.glassName);
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +273,7 @@ export default {
|
||||||
getPassengerSideReplaceOptionsFromStore() {
|
getPassengerSideReplaceOptionsFromStore() {
|
||||||
var passengerSideReplaceOptions = [];
|
var passengerSideReplaceOptions = [];
|
||||||
|
|
||||||
store.getters.damage.glassToReplace?.forEach((glass) => {
|
this.mainStore.getters.damage.glassToReplace?.forEach((glass) => {
|
||||||
if (glass.glassLocation === damageLocationsSelected.PASSENGER) {
|
if (glass.glassLocation === damageLocationsSelected.PASSENGER) {
|
||||||
passengerSideReplaceOptions.push(glass.glassName);
|
passengerSideReplaceOptions.push(glass.glassName);
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +283,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRearReplaceOptionsFromStore() {
|
getRearReplaceOptionsFromStore() {
|
||||||
var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(
|
var rearReplaceOptions = this.mainStore.getters.damage.glassToReplace?.filter(
|
||||||
(glass) => glass.glassLocation === damageLocationsSelected.REAR
|
(glass) => glass.glassLocation === damageLocationsSelected.REAR
|
||||||
)[0]?.glassName;
|
)[0]?.glassName;
|
||||||
|
|
||||||
|
|
@ -328,13 +307,13 @@ export default {
|
||||||
|
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
// If vin already exists, navigate directly to vin-lookup
|
// If vin already exists, navigate directly to vin-lookup
|
||||||
if (store.getters.vehicle.vin) {
|
if (this.mainStore.getters.vehicle.vin) {
|
||||||
this.$router.navigateWithSaving(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.$router.navigateWithSaving(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
this.$route
|
this.$route
|
||||||
);
|
);
|
||||||
|
|
@ -466,12 +445,7 @@ export default {
|
||||||
},
|
},
|
||||||
shouldDisplayVehicleChangeAlert() {
|
shouldDisplayVehicleChangeAlert() {
|
||||||
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT];
|
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT];
|
||||||
},
|
}
|
||||||
shouldHideBackButton() {
|
|
||||||
return (
|
|
||||||
this.$store.getters.payment.insuranceCoverage.isVerified
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,27 @@ const routingTable = function(store) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.SELECTED_STYLE,
|
scenario: navigationScenarios.SELECTED_STYLE,
|
||||||
destinationIssPageValue: issPageValues.WELCOME_PAGE,
|
destinationIssPageValue: issPageValues.VEHICLE_DAMAGE,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
issPageValue: issPageValue.VEHICLE_DAMAGE,
|
||||||
|
maps: [
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_BACK,
|
||||||
|
destinationIssPageValue: issPageValue.VEHICLE_STYLE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN,
|
||||||
|
destinationIssPageValue: issPageValue.WELCOME_PAGE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
|
||||||
|
destinationIssPageValue: issPageValue.WELCOME_PAGE,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
issPageValue: issPageValues.WELCOME_PAGE,
|
issPageValue: issPageValues.WELCOME_PAGE,
|
||||||
maps: [
|
maps: [
|
||||||
|
|
|
||||||
5
src/router/router-params.js
Normal file
5
src/router/router-params.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
const routerParams = {
|
||||||
|
DISPLAY_VEHICLE_CHANGE_ALERT: "displayVehicleChangeAlert",
|
||||||
|
};
|
||||||
|
|
||||||
|
export { routerParams };
|
||||||
|
|
@ -128,6 +128,14 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDamageOptions(carId) {
|
||||||
|
return globalMethods.callHttpClient({
|
||||||
|
methods: endpoints.GetDamageOptions.method,
|
||||||
|
endpoint: `${endpoints.GetDamageOptions.url}/${carId}`,
|
||||||
|
payload: {},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// Vehicle API Actions
|
// Vehicle API Actions
|
||||||
updateVehicleYear(year)
|
updateVehicleYear(year)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue