From 257822394106bad5b19ea72f557d0291c13ff4fa Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Tue, 27 Sep 2022 11:05:58 -0400 Subject: [PATCH 1/4] setting up initial Pinia store state. --- src/main.js | 3 + src/store/index.js | 134 +++++++++++++++++++++++++-------------------- 2 files changed, 79 insertions(+), 58 deletions(-) diff --git a/src/main.js b/src/main.js index 550d42a5..fdeafbb2 100644 --- a/src/main.js +++ b/src/main.js @@ -13,8 +13,11 @@ pinia.use(piniaPluginPersistedstate); vueApp.use(pinia); vueApp.config.globalProperties.$store = useMainStore(); vueApp.mixin(baseMixin); +useMainStore().populateInitialState(); vueApp.use(router); vueApp.mount("#app"); + + diff --git a/src/store/index.js b/src/store/index.js index b35f1ab9..631b009e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,66 +3,80 @@ import { endpoints } from "@/constants/endpoints.js"; import globalMethods from "@/global-methods"; import { storeActions } from "@/constants/store-actions"; +const getDefaultState = () => { + return { + order: { + vehicle: { + year: null, + make: null, + model: null, + style: null, + carId: null, + category: null, + vin: null, + imageUrl: null, + imageVifNumber: null, + imageColor: null, + registration: { + licensePlate: null, + address: null, + city: null, + state: null, + zipCode: null, + firstName: null, + lastName: null, + }, + }, + serviceLocation: { + address: null, + city: null, + state: null, + zipCode: null, + }, + customer: { + emailAddress: null, + }, + damage: { + isRepair: null, + numberOfChips: null, + glassToReplace: null, + partQuestionAnswers: null, + moldingQuestionAnswers: null, + capabilityQuestionAnswers: null + }, + lineItems: { + glassParts: null + }, + payment: { + isInsurance: null, + insuranceCoverage: { + isVerified: null + } + }, + referralNumber: null, + referralDate: null, + referralCorrelationId: null, + accountNumber: 0, + eon: null + }, + applicationUser: { + eventBus: [], + pageData: {}, + saveOrderPromise: null, + savedSessionId: null, + crmCustomerId: null, + lastPageVisited: null, + experiments: [], + triggeredSiteEntry: false + }, + }; +}; + +export const state = getDefaultState(); + export const useMainStore = defineStore({ id: 'main', - state() { - return { - order: { - vehicle: { - year: null, - make: null, - model: null, - style: null, - carId: null, - category: null, - vin: null, - imageUrl: null, - imageVifNumber: null, - imageColor: null, - registration: { - licensePlate: null, - address: null, - city: null, - state: null, - zipCode: null, - firstName: null, - lastName: null, - }, - }, - serviceLocation: { - address: null, - city: null, - state: null, - zipCode: null, - }, - customer: { - emailAddress: null, - }, - damage: { - isRepair: null, - numberOfChips: null, - glassToReplace: null, - partQuestionAnswers: null, - moldingQuestionAnswers: null, - capabilityQuestionAnswers: null - }, - lineItems: { - glassParts: null - }, - payment: { - isInsurance: null, - insuranceCoverage: { - isVerified: null - } - }, - referralNumber: null, - referralDate: null, - referralCorrelationId: null, - accountNumber: 0, - eon: null - }, - }; - }, + state: () => state, getters: {}, actions: { @@ -82,6 +96,10 @@ export const useMainStore = defineStore({ this.updateYear(year); } }, + populateInitialState() + { + Object.assign(this.$state, getDefaultState()); + } }, persist: true }); From 107dace02cd1e3d0e74c5f3f5151113996c9a62d Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Tue, 27 Sep 2022 15:14:56 -0400 Subject: [PATCH 2/4] commit --- src/store/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 631b009e..64b58369 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -98,7 +98,10 @@ export const useMainStore = defineStore({ }, populateInitialState() { - Object.assign(this.$state, getDefaultState()); + if(!localStorage.getItem('main')) { + this.$state = state; + } + } }, persist: true From 7408912c2e4bfd9f37f03d8c76c8f5ebc1e56b5e Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Fri, 30 Sep 2022 08:13:51 -0400 Subject: [PATCH 3/4] commit --- src/store/index.js | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 64b58369..8cfec026 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -27,37 +27,9 @@ const getDefaultState = () => { lastName: null, }, }, - serviceLocation: { - address: null, - city: null, - state: null, - zipCode: null, - }, - customer: { - emailAddress: null, - }, - damage: { - isRepair: null, - numberOfChips: null, - glassToReplace: null, - partQuestionAnswers: null, - moldingQuestionAnswers: null, - capabilityQuestionAnswers: null - }, - lineItems: { - glassParts: null - }, - payment: { - isInsurance: null, - insuranceCoverage: { - isVerified: null - } - }, referralNumber: null, referralDate: null, - referralCorrelationId: null, accountNumber: 0, - eon: null }, applicationUser: { eventBus: [], @@ -98,7 +70,8 @@ export const useMainStore = defineStore({ }, populateInitialState() { - if(!localStorage.getItem('main')) { + const storeId = 'main'; + if(!localStorage.getItem(storeId)) { this.$state = state; } From 9b92943db01c5f70fb5293dca3ab127a7e293778 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Fri, 30 Sep 2022 09:09:48 -0400 Subject: [PATCH 4/4] Some suggested edits --- src/constants/application-config.js | 1 + src/constants/endpoints.js | 60 ----------------------- src/constants/store-actions.js | 37 -------------- src/layouts/vehicle-make/vehicle-make.vue | 1 - src/main.js | 7 ++- src/store/index.js | 22 ++------- vue.config.js | 3 +- 7 files changed, 11 insertions(+), 120 deletions(-) diff --git a/src/constants/application-config.js b/src/constants/application-config.js index 70777398..ff2229e3 100644 --- a/src/constants/application-config.js +++ b/src/constants/application-config.js @@ -1,5 +1,6 @@ const applicationConfig = { CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT, // "Localhost", "Dev", "QA", and "Prod" + CONSUMER_CF_DISTRO: process.env.VUE_APP_CONSUMER_CF_DISTRO, APPLICATION_NAME: "SelfService", SITE_ENTRY_TRIGGER_VALUE: "SelfService" }; diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 9021ded4..7581f022 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -7,70 +7,10 @@ const endpoints = { url: "/content/api/v1/content/HomepageInfo", method: "GET", }, - GetVehicleYears: { - url: "/vehicle/api/v1/vehicle/years", - method: "GET", - }, - GetVehicleMakes: { - url: "/vehicle/api/v1/vehicle/Makes", - method: "GET", - }, - GetVehicleModels: { - url: "/vehicle/api/v1/vehicle/Models", - method: "GET", - }, - GetVehicleStyles: { - url: "/vehicle/api/v1/vehicle/Styles", - method: "GET", - }, - GetVehicle: { - url: "/vehicle/api/v1/vehicle/lookup", - method: "GET", - }, - GetDamageOptions: { - url: "/parts/api/v1/parts/damage-options", - method: "GET", - }, GetPageData: { url: "/content/api/v1/content", method: "GET", }, - LookupVehicleByYmms: { - url: "/vehicle/api/v1/vehicle/Lookup", - method: "GET", - }, - LookupVehicleByVin: { - url: "/vehicle/api/v1/vehicle/Lookup", - method: "POST", - }, - LookupVinByPlate: { - url: "/vehicle/api/v1/vehicle/lookup-vin-by-plate", - method: "POST", - }, - LookupVinByAddress: { - url: "/vehicle/api/v1/vehicle/lookup-vin-by-address", - method: "POST", - }, - GetPartsOrQuestions: { - url: "/parts/api/v1/parts/parts-or-questions", - method: "POST", - }, - GetParts: { - url: "/parts/api/v1/parts/parts", - method: "POST", - }, - GetCapabilityQuestions: { - url: "/parts/api/v1/parts/capability-questions", - method: "GET" - }, - GetPartFromCapabilityAnswer: { - url: "/parts/api/v1/parts/part-from-capability-answer", - method: "POST" - }, - ValidateZip: { - url: "/location/api/v1/location/zip", - method: "GET", - } }; export { endpoints }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 7912446a..ff3d60fb 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -3,43 +3,6 @@ const storeActions = { GET_ROUTE_INFO_ACTION: "getRouteInfo", GET_HOMEPAGE_NAME: "getHomepageName", GET_PAGE_DATA: "getPageData", - - // Vehicle Actions - GET_VEHICLE_YEARS: "getVehicleYears", - GET_VEHICLE_MAKES: "getVehicleMakes", - GET_VEHICLE_MODELS: "getVehicleModels", - GET_VEHICLE_STYLES: "getVehicleStyles", - SET_VEHICLE: "setVehicle", - GET_DAMAGE_OPTIONS: "getDamageOptions", - GET_EVOX_IMAGE: "getEvoxImage", - - // Lookup Actions - LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", - LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin", - LOOKUP_VIN_BY_PLATE: "lookupVinByPlate", - LOOKUP_VIN_BY_ADDRESS: "lookupVinByAddress", - - GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", - GET_PARTS: "getParts", - GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions", - GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer", - GET_MOLDING_QUESTIONS: "getMoldingQuestions", - VALIDATE_ZIP: "validateZip", - CLEAR_VIN: "clearVin", - - // VEHICLE Actions - UPDATE_YEAR: "updateYear", - UPDATE_MAKE: "updateMake", - UPDATE_MODEL: "updateModel", - UPDATE_STYLE: "updateStyle", - UPDATE_CAR_ID: "updateCarId", - UPDATE_VEHICLE_CATEGORY: "updateVehicleCategory", - UPDATE_VEHICLE_IMAGE_URL: "updateVehicleImageUrl", - UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber", - UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor", - UPDATE_VEHICLE_VIN: "updateVehicleVin", - UPDATE_VEHICLE: "updateVehicle", - }; export { storeActions }; diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index cb13bd16..156d9162 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -8,7 +8,6 @@