This commit is contained in:
Kulbhushan Kaushik 2022-11-10 12:15:30 -05:00
parent 120369c5bc
commit 2ba1f71767
6 changed files with 61 additions and 54 deletions

View file

@ -26,7 +26,11 @@ const endpoints = {
GetVehicleStyles: {
url: "/vehicle/api/v1/vehicle/styles",
method: "GET",
}
},
GetDamageOptions: {
url: "/parts/api/v1/parts/damage-options",
method: "GET",
},
};
export { endpoints };

View file

@ -42,7 +42,6 @@
<script>
import buttonQuestion from "@/common-components/button-question/button-question";
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
import { useMainStore } from '@/store';
import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
@ -133,7 +132,7 @@ export default {
const filteredAnswers = Array.isArray(this.answersFromCms)
? this.answersFromCms.filter((ans) => {
const name = ans.Name.split("-");
return name[0].toUpperCase() === store.getters.vehicle.category;
return name[0].toUpperCase() === this.mainStore.getters.vehicle.category;
})
: [];

View file

@ -48,7 +48,6 @@
<site-footer
cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid"
:isBackButtonHidden="shouldHideBackButton"
@back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction" />
</div>
@ -71,15 +70,12 @@ import alert from "@/ux-components/alert/alert";
// Supporting files
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 store from "@/store";
import baseMixin from "@/mixins/base-mixin";
import { useMainStore } from '@/store';
// DEFINE VALIDATION RULES
defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED));
@ -88,11 +84,8 @@ export default {
name: "vehicle-damage",
async beforeRouteEnter(to, from, next) {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
const damageOptionsPromise = baseMixin.methods.dispatchStoreAction(
storeActions.GET_DAMAGE_OPTIONS,
{ carId: store.getters.vehicle.carId }
);
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const damageOptionsPromise = useMainStore().getDamageOptions(useMainStore().getters.vehicle.carId);
// Settle promises and get results
const promiseResultMap = [
@ -136,46 +129,32 @@ export default {
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
};
},
mounted() {
this.attachCustomEvents();
},
methods: {
arePagePrerequisitesValid() {
if (store.getters.vehicle.carId) {
if (this.mainStore.order.vehicle.carId) {
return 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.$route);
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
},
getDamageLocationsFromStore() {
var glassSelections = [];
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.WINDSHIELD;
}) ||
store.getters.damage.isRepair
this.mainStore.getters.damage.isRepair
) {
glassSelections.push(damageLocationsSelected.WINDSHIELD);
}
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return (
glass.glassLocation === damageLocationsSelected.DRIVER ||
glass.glassLocation === damageLocationsSelected.PASSENGER
@ -186,7 +165,7 @@ export default {
}
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.REAR;
})
) {
@ -203,14 +182,14 @@ export default {
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.selectedWindshieldChipCount = store.getters.damage.numberOfChips;
windShieldOptions.selectedWindshieldChipCount = this.mainStore.getters.damage.numberOfChips;
} else {
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return (
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.glassName === damageLocationsSelected.SINGLE
@ -225,7 +204,7 @@ export default {
}
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return (
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.glassName === damageLocationsSelected.DRIVER
@ -240,7 +219,7 @@ export default {
}
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return (
glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
glass.glassName === damageLocationsSelected.PASSENGER
@ -261,7 +240,7 @@ export default {
getDoorSidesFromStore() {
var doorSides = [];
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.DRIVER;
})
) {
@ -269,7 +248,7 @@ export default {
}
if (
store.getters.damage.glassToReplace?.some((glass) => {
this.mainStore.getters.damage.glassToReplace?.some((glass) => {
return glass.glassLocation === damageLocationsSelected.PASSENGER;
})
) {
@ -282,7 +261,7 @@ export default {
getDriverSideReplaceOptionsFromStore() {
var driverSideReplaceOptions = [];
store.getters.damage.glassToReplace?.forEach((glass) => {
this.mainStore.getters.damage.glassToReplace?.forEach((glass) => {
if (glass.glassLocation === damageLocationsSelected.DRIVER) {
driverSideReplaceOptions.push(glass.glassName);
}
@ -294,7 +273,7 @@ export default {
getPassengerSideReplaceOptionsFromStore() {
var passengerSideReplaceOptions = [];
store.getters.damage.glassToReplace?.forEach((glass) => {
this.mainStore.getters.damage.glassToReplace?.forEach((glass) => {
if (glass.glassLocation === damageLocationsSelected.PASSENGER) {
passengerSideReplaceOptions.push(glass.glassName);
}
@ -304,7 +283,7 @@ export default {
},
getRearReplaceOptionsFromStore() {
var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(
var rearReplaceOptions = this.mainStore.getters.damage.glassToReplace?.filter(
(glass) => glass.glassLocation === damageLocationsSelected.REAR
)[0]?.glassName;
@ -328,13 +307,13 @@ export default {
navigateForward() {
// If vin already exists, navigate directly to vin-lookup
if (store.getters.vehicle.vin) {
this.$router.navigateWithSaving(
if (this.mainStore.getters.vehicle.vin) {
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_VIN,
this.$route
);
} else {
this.$router.navigateWithSaving(
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
this.$route
);
@ -466,12 +445,7 @@ export default {
},
shouldDisplayVehicleChangeAlert() {
return this.$route.params[this.routerParams.DISPLAY_VEHICLE_CHANGE_ALERT];
},
shouldHideBackButton() {
return (
this.$store.getters.payment.insuranceCoverage.isVerified
);
},
}
},
components: {

View file

@ -52,10 +52,27 @@ const routingTable = function(store) {
},
{
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,
maps: [

View file

@ -0,0 +1,5 @@
const routerParams = {
DISPLAY_VEHICLE_CHANGE_ALERT: "displayVehicleChangeAlert",
};
export { routerParams };

View file

@ -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
updateVehicleYear(year)
{