Initial add of SaveSession

This commit is contained in:
brydon1 2023-07-13 12:04:01 -04:00
parent 8c78204602
commit c7f54b8b7e
3 changed files with 273 additions and 144 deletions

View file

@ -1,136 +1,142 @@
const endpoints = { const endpoints = {
GetRouteInfo: { GetRouteInfo: {
url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/RouteInfo`, url: (applicationAbbreviation) =>
method: 'POST' `/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'
}, },
GetServiceabilityDetails: { GetHomepageInfo: {
url: "/location/api/v1/location/serviceability-details", url: (applicationAbbreviation) =>
method: "GET", `/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`,
}, method: 'GET'
GetVehicle: { },
url: '/vehicle/api/v1/vehicle/lookup', GetPageData: {
method: 'GET' url: (applicationAbbreviation, pageName) =>
}, `/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
LogExperimentExposureIfAssigned: { method: 'GET'
url: '/experiments/api/v1/experiments/log-exposure', },
method: 'POST' GetVehicleYears: {
}, url: '/vehicle/api/v1/vehicle/years',
LogPageView: { method: 'GET'
url: '/analytics/api/v1/analytics/log-page-view', },
method: 'POST' GetVehicleMakes: {
}, url: '/vehicle/api/v1/vehicle/makes/',
LogCustomEvent: { method: 'GET'
url: '/analytics/api/v1/analytics/log-custom-event', },
method: 'POST' GetVehicleModels: {
}, url: '/vehicle/api/v1/vehicle/models',
LookupVehicleByVin: { method: 'GET'
url: '/vehicle/api/v1/vehicle/lookup', },
method: 'POST' GetVehicleStyles: {
}, url: '/vehicle/api/v1/vehicle/styles',
LookupVinByAddress: { method: 'GET'
url: '/vehicle/api/v1/vehicle/lookup-vin-by-address', },
method: 'POST' GetDamageOptions: {
}, url: '/parts/api/v1/parts/damage-options',
LookupVinByPlate: { method: 'GET'
url: '/vehicle/api/v1/vehicle/lookup-vin-by-plate', },
method: 'POST' GetPartsOrQuestions: {
}, url: '/parts/api/v1/parts/parts-or-questions',
InitializeSession: { method: 'POST'
url: '/analytics/api/v1/analytics/initialize', },
method: 'POST' GetParts: {
}, url: '/parts/api/v1/parts/parts',
GetExperimentsByUser: { method: 'POST'
url: '/analytics/api/v1/analytics/get-experiments', },
method: 'GET' GetPriceOrderItems: {
}, url: '/price/api/v1/price/order-items',
RunExperimentsForTrigger: { method: 'GET'
url: '/experiments/api/v1/experiments/run', },
method: 'POST' GetCapabilityQuestions: {
}, url: '/parts/api/v1/parts/capability-questions',
ValidateZip: { method: 'GET'
url: '/location/api/v1/location/zip', },
method: 'GET' GetPartFromCapabilityAnswer: {
}, url: '/parts/api/v1/parts/part-from-capability-answer',
GooglePlaces: { method: 'POST'
url: 'https://maps.googleapis.com/maps/api/js?key={apiKey}&libraries=places' },
}, GetWipers: {
ValidateClientTag: { url: '/parts/api/v1/parts/wipers',
url: '/clientauth/api/v1/clientauth/validate-client-tag', method: 'GET'
method: 'GET' },
}, GetRainDefense: {
IsVinbyAddressPermissible:{ url: '/parts/api/v1/parts/rain-defense',
url:'/vehicle/api/v1/vehicle/is-vin-by-address-permissible', method: 'GET'
method:'Get' },
}, GetSupportingItems: {
CoveragePolicyInfo: { url: '/parts/api/v1/parts/supporting-items',
url: '/coverage/api/v1/coverage/get-policy-information', method: 'POST'
method: 'POST' },
}, GetServiceabilityDetails: {
RegisterClaim: { url: '/location/api/v1/location/serviceability-details',
url: '/coverage/api/v1/coverage/register-claim', method: 'GET'
method: 'POST' },
} 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 }; export { endpoints };

View file

@ -1,3 +1,5 @@
/* eslint-disable no-shadow */
/* eslint-disable no-use-before-define */
/* eslint-disable max-len */ /* eslint-disable max-len */
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { endpoints } from '@/constants/endpoints'; import { endpoints } from '@/constants/endpoints';
@ -16,6 +18,7 @@ const storeId = 'main';
const getDefaultState = () => const getDefaultState = () =>
({ ({
order: { order: {
// Same as FMG
vehicle: { vehicle: {
year: null, year: null,
make: null, make: null,
@ -37,6 +40,7 @@ const getDefaultState = () =>
lastName: null lastName: null
} }
}, },
// Same as FMG
damage: { damage: {
isRepair: null, isRepair: null,
numberOfChips: null, numberOfChips: null,
@ -45,6 +49,7 @@ const getDefaultState = () =>
moldingQuestionAnswers: null, moldingQuestionAnswers: null,
capabilityQuestionAnswers: null capabilityQuestionAnswers: null
}, },
// DNE in FMG
policy: { policy: {
policyNumber: null, policyNumber: null,
policyZipCode: null, policyZipCode: null,
@ -59,6 +64,7 @@ const getDefaultState = () =>
replace: null // numerical value; how much customer owes on deductible in replace case, replace: null // numerical value; how much customer owes on deductible in replace case,
} }
}, },
// FMG only has email
customer: { customer: {
address: { address: {
streetAddress: null, streetAddress: null,
@ -72,6 +78,7 @@ const getDefaultState = () =>
emailAddress: null, emailAddress: null,
phoneNumber: null phoneNumber: null
}, },
// Many more details in FMG
serviceLocation: { serviceLocation: {
address: null, address: null,
city: null, city: null,
@ -79,21 +86,24 @@ const getDefaultState = () =>
zipCode: null, zipCode: null,
zipCodeCtu: null zipCodeCtu: null
}, },
// otherParts vs serverData
lineItems: { lineItems: {
glassParts: null, glassParts: null,
otherParts: null, otherParts: null, // TODO what is this?
supportingItems: null, 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: { payment: {
isInsurance: true, isInsurance: true,
insuranceCoverage: { insuranceCoverage: {
isVerified: false, isVerified: false,
coverageStatus: coverageStatuses.PENDING coverageStatus: coverageStatuses.PENDING
} },
parentAccountNumber: 0 // TODO what is this for and where set?
}, },
referralNumber: null, // DNE in FMG
referralDate: null,
contactInfo: { contactInfo: {
firstName: null, firstName: null,
lastName: null, lastName: null,
@ -101,7 +111,18 @@ const getDefaultState = () =>
phoneNumber: null, phoneNumber: null,
requestTextUpdates: false, requestTextUpdates: false,
notesForTechnician: '' 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: { applicationUser: {
experiments: [], 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) { saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort(); const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
const isGlassToReplaceTheSame const isGlassToReplaceTheSame
@ -1177,14 +1300,14 @@ export const useMainStore = defineStore({
}, },
async validateZip({ zip }) { async validateZip({ zip }) {
return await globalMethods.callHttpClient({ return globalMethods.callHttpClient({
methods: endpoints.ValidateZip.method, methods: endpoints.ValidateZip.method,
endpoint: `${endpoints.ValidateZip.url}/${zip}` endpoint: `${endpoints.ValidateZip.url}/${zip}`
}); });
}, },
async validateClientTag(clientTag) { async validateClientTag(clientTag) {
return await globalMethods.callHttpClient({ return globalMethods.callHttpClient({
methods: endpoints.ValidateClientTag.method, methods: endpoints.ValidateClientTag.method,
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}` endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`
}); });

View file

@ -7,11 +7,10 @@ import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '
import { coverageStatuses } from "@/constants/coverage-statuses.js"; import { coverageStatuses } from "@/constants/coverage-statuses.js";
describe("Store", () => { describe("Store", () => {
let store; let store;
const vueApp = createApp(App); const vueApp = createApp(App);
beforeEach(() => { beforeEach(() => {
const pinia = createPinia(); const pinia = createPinia();
setActivePinia(pinia); setActivePinia(pinia);
@ -20,8 +19,7 @@ describe("Store", () => {
store.applicationUser.eventBus = []; store.applicationUser.eventBus = [];
jest.resetAllMocks(); jest.resetAllMocks();
}); });
it("Should Store Vehicle Year", () => { it("Should Store Vehicle Year", () => {
let testYear = "2001"; let testYear = "2001";
store.updateVehicleYear(testYear); store.updateVehicleYear(testYear);
@ -463,4 +461,6 @@ describe("Store", () => {
expect(store.contactInfo.notesForTechnician).toEqual(''); expect(store.contactInfo.notesForTechnician).toEqual('');
}); });
}); });
// TODO add tests
describe('saveSession method', () => {});
}); });