Merge pull request #8 from Safelite/feature/Digital/SSR-47

setting up initial Pinia store state.
This commit is contained in:
Kulbhushan Kaushik 2022-09-30 09:16:47 -04:00 committed by GitHub
commit 2f9b193eb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 171 deletions

View file

@ -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"
};

View file

@ -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 };

View file

@ -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 };

View file

@ -8,7 +8,6 @@
</template>
<script>
import { storeActions } from "@/constants/store-actions";
export default {
name: 'vehicle-make',
methods:

View file

@ -8,13 +8,21 @@ import { useMainStore } from './store';
import baseMixin from "@/mixins/base-mixin.js";
const vueApp = createApp(App);
// Pinia
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
vueApp.use(pinia);
vueApp.config.globalProperties.$store = useMainStore();
useMainStore().populateInitialState();
// Additional Vue items to setup
vueApp.mixin(baseMixin);
vueApp.use(router);
vueApp.mount("#app");

View file

@ -1,80 +1,52 @@
import { defineStore } from "pinia";
import { endpoints } from "@/constants/endpoints.js";
import globalMethods from "@/global-methods";
import { storeActions } from "@/constants/store-actions";
const storeId = 'main';
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,
},
},
referralNumber: null,
referralDate: null,
accountNumber: 0,
},
applicationUser: {
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
},
};
},
id: storeId,
state: () => state,
getters: {},
actions:
{
updateYear(year) {
this.order.vehicle.year = year;
},
updateMake(make) {
this.order.vehicle.make = make;
},
updateModel(model) {
this.order.vehicle.model = model;
},
// Vehicle
saveVehicleYear(year)
{
@ -82,6 +54,12 @@ export const useMainStore = defineStore({
this.updateYear(year);
}
},
populateInitialState()
{
if(!localStorage.getItem(storeId)) {
this.$state = state;
}
}
},
persist: true
});

View file

@ -1,5 +1,4 @@
process.env.VUE_APP_CONSUMER_CF_DISTRO =
"https://consumerapidev.safelite.com";
process.env.VUE_APP_CONSUMER_CF_DISTRO ="https://digitalapi.dev.sagaws.net";
process.env.VUE_APP_CURRENT_ENVIRONMENT = "Localhost";
module.exports = {