import { createStore } from "vuex"; import { endpoints } from "@/constants/endpoints.js"; import createPersistedState from "vuex-persistedstate"; import globalMethods from "@/global-methods"; export default createStore({ plugins: [ createPersistedState({ storage: window.sessionStorage, }), ], state: { order: { vehicle: { year: null, make: null, model: null, style: null, vin: null, licensePlate: null, carId: null, evoxImageId: null, hasSplitWindshieldOption: null, hasBackglassSliderOption: null, registration: { rawAddress: null, zipCode: null, firstName: null, lastName: null, licensePlate: null }, damage: { isRepair: null, isReplacement: null, numberOfChips: null, glassToReplace: null, problemGlassQuestions: null, problemMoldingQuestions: null, problemPropertyQuestions: null, }, items: null, customer: { emailAddress: null, firstName: null, lastName: null, phoneNumber: { isMobile: null, optInSms: null, } }, payment: { isInsurance: null, isCash: null, }, referral: { referralSeqNum: null, workOrderId: null } } }, applicationUser: { experiments: null, } }, mutations: {}, actions: { // Vehicle API Actions getVehicleYears(context) { return globalMethods.callHttpClient({ method: endpoints.GetVehicleYears.method, endpoint: endpoints.GetVehicleYears.url, payload: {}, }); }, getVehicleMakes(context, { year }) { return globalMethods.callHttpClient({ method: endpoints.GetVehicleMakes.method, endpoint: `${endpoints.GetVehicleMakes.url}/${year}`, payload: {}, }); }, getVehicleModels(context, { year, make }) { return globalMethods.callHttpClient({ method: endpoints.GetVehicleModels.method, endpoint: `${endpoints.GetVehicleModels.url}/${year}/${make}`, payload: {}, }); }, getVehicleStyles(context, { year, make, model }) { return globalMethods.callHttpClient({ method: endpoints.GetVehicleStyles.method, endpoint: `${endpoints.GetVehicleStyles.url}/${year}/${make}/${model}`, payload: {}, }); }, // Content API Actions getRouteInfo(context, { pageName }) { return globalMethods.callHttpClient({ method: endpoints.GetRouteInfo.method, endpoint: endpoints.GetRouteInfo.url, payload: { pageName: pageName, }, }); }, getPageData(context, { pageName }) { return globalMethods.callHttpClient({ method: endpoints.GetPageData.method, endpoint: `${endpoints.GetPageData.url}/${pageName}`, payload: {}, }); }, }, });