Initial add of SaveSession
This commit is contained in:
parent
8c78204602
commit
c7f54b8b7e
3 changed files with 273 additions and 144 deletions
|
|
@ -1,136 +1,142 @@
|
|||
const endpoints = {
|
||||
GetRouteInfo: {
|
||||
url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/RouteInfo`,
|
||||
method: 'POST'
|
||||
},
|
||||
GetHomepageInfo: {
|
||||
url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetPageData: {
|
||||
url: (applicationAbbreviation, pageName) => `/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
|
||||
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'
|
||||
},
|
||||
GetDamageOptions: {
|
||||
url: '/parts/api/v1/parts/damage-options',
|
||||
method: 'GET'
|
||||
},
|
||||
GetPartsOrQuestions: {
|
||||
url: '/parts/api/v1/parts/parts-or-questions',
|
||||
method: 'POST'
|
||||
},
|
||||
GetParts: {
|
||||
url: '/parts/api/v1/parts/parts',
|
||||
method: 'POST'
|
||||
},
|
||||
GetPriceOrderItems: {
|
||||
url: '/price/api/v1/price/order-items',
|
||||
method: 'GET'
|
||||
},
|
||||
GetCapabilityQuestions: {
|
||||
url: '/parts/api/v1/parts/capability-questions',
|
||||
method: 'GET'
|
||||
},
|
||||
GetPartFromCapabilityAnswer: {
|
||||
url: '/parts/api/v1/parts/part-from-capability-answer',
|
||||
method: 'POST'
|
||||
},
|
||||
GetWipers: {
|
||||
url: '/parts/api/v1/parts/wipers',
|
||||
method: 'GET'
|
||||
},
|
||||
GetRainDefense: {
|
||||
url: '/parts/api/v1/parts/rain-defense',
|
||||
method: 'GET'
|
||||
},
|
||||
GetSupportingItems: {
|
||||
url: '/parts/api/v1/parts/supporting-items',
|
||||
method: 'POST'
|
||||
GetRouteInfo: {
|
||||
url: (applicationAbbreviation) =>
|
||||
`/content/api/v1/content/${applicationAbbreviation}/RouteInfo`,
|
||||
method: 'POST'
|
||||
},
|
||||
GetServiceabilityDetails: {
|
||||
url: "/location/api/v1/location/serviceability-details",
|
||||
method: "GET",
|
||||
},
|
||||
GetVehicle: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup',
|
||||
method: 'GET'
|
||||
},
|
||||
LogExperimentExposureIfAssigned: {
|
||||
url: '/experiments/api/v1/experiments/log-exposure',
|
||||
method: 'POST'
|
||||
},
|
||||
LogPageView: {
|
||||
url: '/analytics/api/v1/analytics/log-page-view',
|
||||
method: 'POST'
|
||||
},
|
||||
LogCustomEvent: {
|
||||
url: '/analytics/api/v1/analytics/log-custom-event',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVehicleByVin: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVinByAddress: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-address',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVinByPlate: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-plate',
|
||||
method: 'POST'
|
||||
},
|
||||
InitializeSession: {
|
||||
url: '/analytics/api/v1/analytics/initialize',
|
||||
method: 'POST'
|
||||
},
|
||||
GetExperimentsByUser: {
|
||||
url: '/analytics/api/v1/analytics/get-experiments',
|
||||
method: 'GET'
|
||||
},
|
||||
RunExperimentsForTrigger: {
|
||||
url: '/experiments/api/v1/experiments/run',
|
||||
method: 'POST'
|
||||
},
|
||||
ValidateZip: {
|
||||
url: '/location/api/v1/location/zip',
|
||||
method: 'GET'
|
||||
},
|
||||
GooglePlaces: {
|
||||
url: 'https://maps.googleapis.com/maps/api/js?key={apiKey}&libraries=places'
|
||||
},
|
||||
ValidateClientTag: {
|
||||
url: '/clientauth/api/v1/clientauth/validate-client-tag',
|
||||
method: 'GET'
|
||||
},
|
||||
IsVinbyAddressPermissible:{
|
||||
url:'/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
|
||||
method:'Get'
|
||||
},
|
||||
CoveragePolicyInfo: {
|
||||
url: '/coverage/api/v1/coverage/get-policy-information',
|
||||
method: 'POST'
|
||||
},
|
||||
RegisterClaim: {
|
||||
url: '/coverage/api/v1/coverage/register-claim',
|
||||
method: 'POST'
|
||||
}
|
||||
GetHomepageInfo: {
|
||||
url: (applicationAbbreviation) =>
|
||||
`/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetPageData: {
|
||||
url: (applicationAbbreviation, pageName) =>
|
||||
`/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
|
||||
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'
|
||||
},
|
||||
GetDamageOptions: {
|
||||
url: '/parts/api/v1/parts/damage-options',
|
||||
method: 'GET'
|
||||
},
|
||||
GetPartsOrQuestions: {
|
||||
url: '/parts/api/v1/parts/parts-or-questions',
|
||||
method: 'POST'
|
||||
},
|
||||
GetParts: {
|
||||
url: '/parts/api/v1/parts/parts',
|
||||
method: 'POST'
|
||||
},
|
||||
GetPriceOrderItems: {
|
||||
url: '/price/api/v1/price/order-items',
|
||||
method: 'GET'
|
||||
},
|
||||
GetCapabilityQuestions: {
|
||||
url: '/parts/api/v1/parts/capability-questions',
|
||||
method: 'GET'
|
||||
},
|
||||
GetPartFromCapabilityAnswer: {
|
||||
url: '/parts/api/v1/parts/part-from-capability-answer',
|
||||
method: 'POST'
|
||||
},
|
||||
GetWipers: {
|
||||
url: '/parts/api/v1/parts/wipers',
|
||||
method: 'GET'
|
||||
},
|
||||
GetRainDefense: {
|
||||
url: '/parts/api/v1/parts/rain-defense',
|
||||
method: 'GET'
|
||||
},
|
||||
GetSupportingItems: {
|
||||
url: '/parts/api/v1/parts/supporting-items',
|
||||
method: 'POST'
|
||||
},
|
||||
GetServiceabilityDetails: {
|
||||
url: '/location/api/v1/location/serviceability-details',
|
||||
method: 'GET'
|
||||
},
|
||||
GetVehicle: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup',
|
||||
method: 'GET'
|
||||
},
|
||||
LogExperimentExposureIfAssigned: {
|
||||
url: '/experiments/api/v1/experiments/log-exposure',
|
||||
method: 'POST'
|
||||
},
|
||||
LogPageView: {
|
||||
url: '/analytics/api/v1/analytics/log-page-view',
|
||||
method: 'POST'
|
||||
},
|
||||
LogCustomEvent: {
|
||||
url: '/analytics/api/v1/analytics/log-custom-event',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVehicleByVin: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVinByAddress: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-address',
|
||||
method: 'POST'
|
||||
},
|
||||
LookupVinByPlate: {
|
||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-plate',
|
||||
method: 'POST'
|
||||
},
|
||||
InitializeSession: {
|
||||
url: '/analytics/api/v1/analytics/initialize',
|
||||
method: 'POST'
|
||||
},
|
||||
GetExperimentsByUser: {
|
||||
url: '/analytics/api/v1/analytics/get-experiments',
|
||||
method: 'GET'
|
||||
},
|
||||
RunExperimentsForTrigger: {
|
||||
url: '/experiments/api/v1/experiments/run',
|
||||
method: 'POST'
|
||||
},
|
||||
ValidateZip: {
|
||||
url: '/location/api/v1/location/zip',
|
||||
method: 'GET'
|
||||
},
|
||||
GooglePlaces: {
|
||||
url: 'https://maps.googleapis.com/maps/api/js?key={apiKey}&libraries=places'
|
||||
},
|
||||
ValidateClientTag: {
|
||||
url: '/clientauth/api/v1/clientauth/validate-client-tag',
|
||||
method: 'GET'
|
||||
},
|
||||
IsVinbyAddressPermissible:{
|
||||
url: '/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
|
||||
method: 'Get'
|
||||
},
|
||||
CoveragePolicyInfo: {
|
||||
url: '/coverage/api/v1/coverage/get-policy-information',
|
||||
method: 'POST'
|
||||
},
|
||||
RegisterClaim: {
|
||||
url: '/coverage/api/v1/coverage/register-claim',
|
||||
method: 'POST'
|
||||
},
|
||||
SaveSession: {
|
||||
url: '/order/api/v1/order/save-session',
|
||||
method: 'POST'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export { endpoints };
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable no-use-before-define */
|
||||
/* eslint-disable max-len */
|
||||
import { defineStore } from 'pinia';
|
||||
import { endpoints } from '@/constants/endpoints';
|
||||
|
|
@ -16,6 +18,7 @@ const storeId = 'main';
|
|||
const getDefaultState = () =>
|
||||
({
|
||||
order: {
|
||||
// Same as FMG
|
||||
vehicle: {
|
||||
year: null,
|
||||
make: null,
|
||||
|
|
@ -37,6 +40,7 @@ const getDefaultState = () =>
|
|||
lastName: null
|
||||
}
|
||||
},
|
||||
// Same as FMG
|
||||
damage: {
|
||||
isRepair: null,
|
||||
numberOfChips: null,
|
||||
|
|
@ -45,6 +49,7 @@ const getDefaultState = () =>
|
|||
moldingQuestionAnswers: null,
|
||||
capabilityQuestionAnswers: null
|
||||
},
|
||||
// DNE in FMG
|
||||
policy: {
|
||||
policyNumber: null,
|
||||
policyZipCode: null,
|
||||
|
|
@ -59,6 +64,7 @@ const getDefaultState = () =>
|
|||
replace: null // numerical value; how much customer owes on deductible in replace case,
|
||||
}
|
||||
},
|
||||
// FMG only has email
|
||||
customer: {
|
||||
address: {
|
||||
streetAddress: null,
|
||||
|
|
@ -72,6 +78,7 @@ const getDefaultState = () =>
|
|||
emailAddress: null,
|
||||
phoneNumber: null
|
||||
},
|
||||
// Many more details in FMG
|
||||
serviceLocation: {
|
||||
address: null,
|
||||
city: null,
|
||||
|
|
@ -79,21 +86,24 @@ const getDefaultState = () =>
|
|||
zipCode: null,
|
||||
zipCodeCtu: null
|
||||
},
|
||||
// otherParts vs serverData
|
||||
lineItems: {
|
||||
glassParts: null,
|
||||
otherParts: null,
|
||||
otherParts: null, // TODO what is this?
|
||||
supportingItems: null,
|
||||
vaps: null
|
||||
vaps: null,
|
||||
serverData: null // TODO what is this for and should it be added?
|
||||
},
|
||||
// Add parent account number from FMG
|
||||
payment: {
|
||||
isInsurance: true,
|
||||
insuranceCoverage: {
|
||||
isVerified: false,
|
||||
coverageStatus: coverageStatuses.PENDING
|
||||
}
|
||||
},
|
||||
parentAccountNumber: 0 // TODO what is this for and where set?
|
||||
},
|
||||
referralNumber: null,
|
||||
referralDate: null,
|
||||
// DNE in FMG
|
||||
contactInfo: {
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
|
|
@ -101,7 +111,18 @@ const getDefaultState = () =>
|
|||
phoneNumber: null,
|
||||
requestTextUpdates: false,
|
||||
notesForTechnician: ''
|
||||
}
|
||||
},
|
||||
schedule: {
|
||||
date: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
routeCode: null,
|
||||
jobMaxMinutes: null
|
||||
},
|
||||
referralNumber: null,
|
||||
referralDate: null,
|
||||
referralCorrelationId: null, // TODO when is this set
|
||||
eon: null // TODO what is this
|
||||
},
|
||||
applicationUser: {
|
||||
experiments: [],
|
||||
|
|
@ -679,6 +700,108 @@ export const useMainStore = defineStore({
|
|||
});
|
||||
},
|
||||
|
||||
saveSession() {
|
||||
// TODO use pieces of actual store
|
||||
const { vehicle, damage, order, applicationUser, lineItems } = this.order;
|
||||
|
||||
// TODO what does this method do
|
||||
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace);
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url,
|
||||
// TODO update with payload for our store
|
||||
payload: {
|
||||
applicationUser: {
|
||||
crmCustomerId: applicationUser.crmCustomerId,
|
||||
experiments: applicationUser.experiments,
|
||||
lastPage: applicationUser.lastPageVisited,
|
||||
pageData: applicationUser.pageData,
|
||||
savedSessionId: applicationUser.savedSessionId,
|
||||
},
|
||||
order: {
|
||||
vehicle: {
|
||||
carId: vehicle.carId,
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
vin: vehicle.vin,
|
||||
registration: {
|
||||
firstName: vehicle.registration.firstName,
|
||||
lastName: vehicle.registration.lastName,
|
||||
streetAddress: vehicle.registration.address,
|
||||
city: vehicle.registration.city,
|
||||
state: vehicle.registration.state,
|
||||
zipCode: vehicle.registration.zipCode,
|
||||
licensePlateNumber: vehicle.registration.licensePlate,
|
||||
},
|
||||
},
|
||||
customer: {
|
||||
emailAddress: order.customer.emailAddress,
|
||||
},
|
||||
damage: {
|
||||
numberOfChips: damage.numberOfChips,
|
||||
glassToReplace: newGlassToReplace,
|
||||
isRepair: damage.isRepair,
|
||||
partQuestionAnswers: order.damage.partQuestionAnswers,
|
||||
moldingQuestionAnswers: order.damage.moldingQuestionAnswers,
|
||||
capabilityQuestionAnswers: order.damage.capabilityQuestionAnswers,
|
||||
},
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps,
|
||||
serverData: lineItems.serverData,
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
isVerified: order.payment.insuranceCoverage.isVerified ?? false,
|
||||
},
|
||||
isInsurance: order.payment.isInsurance ?? false,
|
||||
parentAccountNumber: order.payment.parentAccountNumber,
|
||||
},
|
||||
serviceLocation: {
|
||||
streetAddress: order.serviceLocation.address,
|
||||
streetAddress2: order.serviceLocation.address2,
|
||||
city: order.serviceLocation.city,
|
||||
state: order.serviceLocation.state,
|
||||
zipCode: order.serviceLocation.zipCode,
|
||||
zipCodeCtu: order.serviceLocation.zipCodeCtu,
|
||||
appointmentType: order.serviceLocation.appointmentType,
|
||||
isVehicleProtected: order.serviceLocation.isVehicleProtected,
|
||||
provider: {
|
||||
providerNumber: order.serviceLocation.provider?.providerNumber,
|
||||
address: {
|
||||
streetAddress:
|
||||
order.serviceLocation.provider?.address?.streetAddress,
|
||||
city: order.serviceLocation.provider?.address?.city,
|
||||
state: order.serviceLocation.provider?.address?.state,
|
||||
zipCode: order.serviceLocation.provider?.address?.zipCode,
|
||||
zipCodeCtu: order.serviceLocation.provider?.address?.zipCodeCtu,
|
||||
},
|
||||
},
|
||||
},
|
||||
schedule: {
|
||||
date: order.schedule?.date,
|
||||
startTime: order.schedule?.startTime,
|
||||
endTime: order.schedule?.endTime,
|
||||
routeCode: order.schedule?.routeCode,
|
||||
jobMaxMinutes: order.schedule?.jobMaxMinutes,
|
||||
},
|
||||
existingPromoCode: null,
|
||||
referralCorrelationId: order.referralCorrelationId,
|
||||
referralDate: order.referralDate,
|
||||
referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place
|
||||
referralSequenceNumber: order.referralNumber?.toString(), // TODO Pass the referralSequence number once insurance flow creates it
|
||||
eon: order.eon
|
||||
}
|
||||
},
|
||||
additionalSuccessEventDataHandler: (response) =>
|
||||
`Email provided: ${order.customer.emailAddress ? 'true' : 'false'}`
|
||||
});
|
||||
},
|
||||
|
||||
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
||||
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||
const isGlassToReplaceTheSame
|
||||
|
|
@ -1177,14 +1300,14 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
async validateZip({ zip }) {
|
||||
return await globalMethods.callHttpClient({
|
||||
return globalMethods.callHttpClient({
|
||||
methods: endpoints.ValidateZip.method,
|
||||
endpoint: `${endpoints.ValidateZip.url}/${zip}`
|
||||
});
|
||||
},
|
||||
|
||||
async validateClientTag(clientTag) {
|
||||
return await globalMethods.callHttpClient({
|
||||
return globalMethods.callHttpClient({
|
||||
methods: endpoints.ValidateClientTag.method,
|
||||
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@ import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '
|
|||
import { coverageStatuses } from "@/constants/coverage-statuses.js";
|
||||
|
||||
describe("Store", () => {
|
||||
|
||||
let store;
|
||||
|
||||
const vueApp = createApp(App);
|
||||
|
||||
|
||||
beforeEach(() => {
|
||||
const pinia = createPinia();
|
||||
setActivePinia(pinia);
|
||||
|
|
@ -20,8 +19,7 @@ describe("Store", () => {
|
|||
store.applicationUser.eventBus = [];
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
|
||||
|
||||
it("Should Store Vehicle Year", () => {
|
||||
let testYear = "2001";
|
||||
store.updateVehicleYear(testYear);
|
||||
|
|
@ -463,4 +461,6 @@ describe("Store", () => {
|
|||
expect(store.contactInfo.notesForTechnician).toEqual('');
|
||||
});
|
||||
});
|
||||
// TODO add tests
|
||||
describe('saveSession method', () => {});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue