Merge pull request #431 from Safelite/feature/richardson/SSR-362.1
service location pre req updates
This commit is contained in:
commit
a81bf8cd4b
3 changed files with 80 additions and 84 deletions
|
|
@ -118,10 +118,7 @@ export default {
|
||||||
|
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.setData(
|
vm.setData(resultMap.zipCodeData, resultMap.serviceabilityDetails);
|
||||||
resultMap.zipCodeData,
|
|
||||||
resultMap.serviceabilityDetails
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
@ -172,8 +169,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisiteValid() {
|
arePagePrerequisitesValid() {
|
||||||
return true;
|
return (
|
||||||
|
useMainStore().lineItems.supportingItems !== null
|
||||||
|
&& useMainStore().order.serviceLocation.zipCode !== null
|
||||||
|
);
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -325,14 +325,16 @@ export default {
|
||||||
const policy = policyInfo.policies?.[0];
|
const policy = policyInfo.policies?.[0];
|
||||||
if (policy) {
|
if (policy) {
|
||||||
// populate policy holder details from policy lookup
|
// populate policy holder details from policy lookup
|
||||||
this.mainStore.order.customer.address.streetAddress =
|
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
||||||
policy.insureds?.[0]?.address;
|
|
||||||
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
||||||
this.mainStore.order.customer.address.state = policy.insureds?.[0]?.state;
|
this.mainStore.order.customer.address.state = policy.insureds?.[0]?.state;
|
||||||
this.mainStore.order.customer.address.zipCode = policy.insureds?.[0]?.zipCode;
|
this.mainStore.order.customer.address.zipCode = policy.insureds?.[0]?.zipCode;
|
||||||
this.mainStore.order.customer.firstName = policy.insureds?.[0]?.firstName;
|
this.mainStore.order.customer.firstName = policy.insureds?.[0]?.firstName;
|
||||||
this.mainStore.order.customer.lastName = policy.insureds?.[0]?.lastName;
|
this.mainStore.order.customer.lastName = policy.insureds?.[0]?.lastName;
|
||||||
|
|
||||||
|
// populate additional fields
|
||||||
|
this.mainStore.order.serviceLocation.zipCode = policy.insureds?.[0]?.zipCode;
|
||||||
|
|
||||||
// populate vehicles
|
// populate vehicles
|
||||||
this.vehiclesFound = policy.vehicles;
|
this.vehiclesFound = policy.vehicles;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* 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';
|
||||||
|
|
@ -203,26 +204,33 @@ export const useMainStore = defineStore({
|
||||||
issIsCoverageVerified: state.order.payment.insuranceCoverage.isVerified,
|
issIsCoverageVerified: state.order.payment.insuranceCoverage.isVerified,
|
||||||
issHasRecalibrationPart: getHasRecalibrationPart(state),
|
issHasRecalibrationPart: getHasRecalibrationPart(state),
|
||||||
issSelectedMultiGlass: state.order.damage.glassToReplace?.length > 1,
|
issSelectedMultiGlass: state.order.damage.glassToReplace?.length > 1,
|
||||||
issSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace,
|
issSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, 'glassLocation')
|
||||||
'glassLocation').includes(damageLocationsSelected.WINDSHIELD),
|
.includes(damageLocationsSelected.WINDSHIELD),
|
||||||
issSelectedBackGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace,
|
issSelectedBackGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, 'glassLocation')
|
||||||
'glassLocation').includes(damageLocationsSelected.REAR),
|
.includes(damageLocationsSelected.REAR),
|
||||||
issSelectedDriverSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace,
|
issSelectedDriverSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, 'glassLocation')
|
||||||
'glassLocation').includes(damageLocationsSelected.DRIVER),
|
.includes(damageLocationsSelected.DRIVER),
|
||||||
issSelectedPassengerSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace,
|
issSelectedPassengerSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, 'glassLocation')
|
||||||
'glassLocation').includes(damageLocationsSelected.PASSENGER),
|
.includes(damageLocationsSelected.PASSENGER),
|
||||||
issOrderPartNumbers: [
|
issOrderPartNumbers: [
|
||||||
...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts,
|
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||||
'partNumber'),
|
state.order.lineItems.glassParts,
|
||||||
...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts,
|
'partNumber'
|
||||||
'partNumber')
|
),
|
||||||
|
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||||
|
state.order.lineItems.otherParts,
|
||||||
|
'partNumber'
|
||||||
|
)
|
||||||
],
|
],
|
||||||
|
|
||||||
issOrderPartTypes: [
|
issOrderPartTypes: [
|
||||||
...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts,
|
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||||
'recalibrationType'),
|
state.order.lineItems.glassParts,
|
||||||
...getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts,
|
'recalibrationType'
|
||||||
'recalibrationType')
|
),
|
||||||
|
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||||
|
state.order.lineItems.otherParts,
|
||||||
|
'recalibrationType'
|
||||||
|
)
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
experimentSettings: (state) => state.applicationUser.experiments
|
experimentSettings: (state) => state.applicationUser.experiments
|
||||||
|
|
@ -599,8 +607,7 @@ export const useMainStore = defineStore({
|
||||||
async getPriceOrderItems(availableLineItems) {
|
async getPriceOrderItems(availableLineItems) {
|
||||||
let zipCodeToUse = this.order.serviceLocation.zipCode;
|
let zipCodeToUse = this.order.serviceLocation.zipCode;
|
||||||
let ctuToUse = this.order.serviceLocation.zipCodeCtu;
|
let ctuToUse = this.order.serviceLocation.zipCodeCtu;
|
||||||
const availableLineItemsFormattedForRequest
|
const availableLineItemsFormattedForRequest = getLineItemQueryStringForPricing(availableLineItems);
|
||||||
= getLineItemQueryStringForPricing(availableLineItems);
|
|
||||||
const { vehicle } = this.order;
|
const { vehicle } = this.order;
|
||||||
|
|
||||||
// WARNING
|
// WARNING
|
||||||
|
|
@ -608,8 +615,8 @@ export const useMainStore = defineStore({
|
||||||
// and ctu is available. Also, EON may need to be implemented.
|
// and ctu is available. Also, EON may need to be implemented.
|
||||||
zipCodeToUse = '44902';
|
zipCodeToUse = '44902';
|
||||||
ctuToUse = '01820';
|
ctuToUse = '01820';
|
||||||
const queryString
|
const queryString =
|
||||||
= `ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}`
|
`ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}`
|
||||||
+ `&CTU=${ctuToUse}`
|
+ `&CTU=${ctuToUse}`
|
||||||
+ `&CarId=${vehicle.carId}`
|
+ `&CarId=${vehicle.carId}`
|
||||||
+ `&Make=${vehicle.make}`
|
+ `&Make=${vehicle.make}`
|
||||||
|
|
@ -637,16 +644,14 @@ export const useMainStore = defineStore({
|
||||||
const lineItemsWithOnlyPartNumbers = this.order.lineItems.glassParts.map((glassPart) => ({
|
const lineItemsWithOnlyPartNumbers = this.order.lineItems.glassParts.map((glassPart) => ({
|
||||||
partNumber: glassPart.partNumber
|
partNumber: glassPart.partNumber
|
||||||
}));
|
}));
|
||||||
const lineItems = buildQueryStringParameterFromArrayOfComplexObjects(lineItemsWithOnlyPartNumbers,
|
const lineItems = buildQueryStringParameterFromArrayOfComplexObjects(lineItemsWithOnlyPartNumbers, 'lineItems');
|
||||||
'lineItems');
|
|
||||||
|
|
||||||
const { vehicle } = this.order;
|
const { vehicle } = this.order;
|
||||||
const { carId } = vehicle;
|
const { carId } = vehicle;
|
||||||
const { damage } = this.order;
|
const { damage } = this.order;
|
||||||
const glassArray = convertGlassPieceNamingForApi(damage.glassToReplace);
|
const glassArray = convertGlassPieceNamingForApi(damage.glassToReplace);
|
||||||
|
|
||||||
const glassPieces = buildQueryStringParameterFromArrayOfComplexObjects(glassArray,
|
const glassPieces = buildQueryStringParameterFromArrayOfComplexObjects(glassArray, 'glassPieces');
|
||||||
'glassPieces');
|
|
||||||
|
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetServiceabilityDetails.method,
|
method: endpoints.GetServiceabilityDetails.method,
|
||||||
|
|
@ -679,23 +684,16 @@ export const useMainStore = defineStore({
|
||||||
|
|
||||||
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
||||||
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||||
const isGlassToReplaceTheSame
|
const isGlassToReplaceTheSame = this.order.damage.glassToReplace?.length === selectedGlassToReplace.length
|
||||||
= this.order.damage.glassToReplace?.length === selectedGlassToReplace.length
|
&& this.order.damage.glassToReplace
|
||||||
&& this.order.damage.glassToReplace
|
.slice()
|
||||||
.slice()
|
.sort()
|
||||||
.sort()
|
.every((obj, index) => obj.glassLocation === selectedGlassPassedInSorted[index].glassLocation
|
||||||
.every((obj, index) => obj.glassLocation === selectedGlassPassedInSorted[index].glassLocation
|
|
||||||
&& obj.glassName === selectedGlassPassedInSorted[index].glassName);
|
&& obj.glassName === selectedGlassPassedInSorted[index].glassName);
|
||||||
const isWindshieldRepairTheSame
|
const isWindshieldRepairTheSame = isWindshieldRepair === this.order.damage.isRepair;
|
||||||
= isWindshieldRepair === this.order.damage.isRepair;
|
const isChipCountTheSame = selectedWindshieldChipCount === this.order.damage.numberOfChips;
|
||||||
|
const isDamageChanging = !isGlassToReplaceTheSame || !isWindshieldRepairTheSame
|
||||||
const isChipCountTheSame
|
|| (isWindshieldRepair && !isChipCountTheSame);
|
||||||
= selectedWindshieldChipCount === this.order.damage.numberOfChips;
|
|
||||||
|
|
||||||
const isDamageChanging
|
|
||||||
= !isGlassToReplaceTheSame
|
|
||||||
|| !isWindshieldRepairTheSame
|
|
||||||
|| (isWindshieldRepair && !isChipCountTheSame);
|
|
||||||
|
|
||||||
if (isDamageChanging) {
|
if (isDamageChanging) {
|
||||||
// Reset dependent state when changing
|
// Reset dependent state when changing
|
||||||
|
|
@ -927,16 +925,14 @@ export const useMainStore = defineStore({
|
||||||
this.order.customer.address.zipCode = customerQuestions.addressQuestions.zipCode;
|
this.order.customer.address.zipCode = customerQuestions.addressQuestions.zipCode;
|
||||||
this.order.customer.firstName = customerQuestions.firstName;
|
this.order.customer.firstName = customerQuestions.firstName;
|
||||||
this.order.customer.lastName = customerQuestions.lastName;
|
this.order.customer.lastName = customerQuestions.lastName;
|
||||||
|
this.order.serviceLocation.zipCode = customerQuestions.addressQuestions.zipCode;
|
||||||
},
|
},
|
||||||
savePartQuestionAnswers(partQuestionAnswersArray) {
|
savePartQuestionAnswers(partQuestionAnswersArray) {
|
||||||
// if part question answers have changed, reset subsequent question answers
|
// if part question answers have changed, reset subsequent question answers
|
||||||
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.partQuestionAnswers,
|
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.partQuestionAnswers, 'result');
|
||||||
'result');
|
const sortedPartQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(partQuestionAnswersArray, 'result');
|
||||||
const sortedPartQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(partQuestionAnswersArray,
|
const havePartQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedPartQuestionAnswersArray.length
|
||||||
'result');
|
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedPartQuestionAnswersArray[i].result);
|
||||||
const havePartQuestionAnswersChanged
|
|
||||||
= sortedPreviousResultsArray?.length !== sortedPartQuestionAnswersArray.length
|
|
||||||
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedPartQuestionAnswersArray[i].result);
|
|
||||||
|
|
||||||
if (havePartQuestionAnswersChanged) {
|
if (havePartQuestionAnswersChanged) {
|
||||||
this.updateGlassParts(null);
|
this.updateGlassParts(null);
|
||||||
|
|
@ -954,13 +950,10 @@ export const useMainStore = defineStore({
|
||||||
this.updatePartQuestionAnswers(partQuestionAnswersArray);
|
this.updatePartQuestionAnswers(partQuestionAnswersArray);
|
||||||
},
|
},
|
||||||
saveMoldingQuestionAnswers(moldingQuestionAnswersArray) {
|
saveMoldingQuestionAnswers(moldingQuestionAnswersArray) {
|
||||||
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.moldingQuestionAnswers,
|
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.moldingQuestionAnswers, 'result');
|
||||||
'result');
|
const sortedMoldingQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(moldingQuestionAnswersArray, 'result');
|
||||||
const sortedMoldingQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(moldingQuestionAnswersArray,
|
const haveMoldingQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedMoldingQuestionAnswersArray.length
|
||||||
'result');
|
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedMoldingQuestionAnswersArray[i].result);
|
||||||
const haveMoldingQuestionAnswersChanged
|
|
||||||
= sortedPreviousResultsArray?.length !== sortedMoldingQuestionAnswersArray.length
|
|
||||||
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedMoldingQuestionAnswersArray[i].result);
|
|
||||||
|
|
||||||
if (haveMoldingQuestionAnswersChanged) {
|
if (haveMoldingQuestionAnswersChanged) {
|
||||||
this.updateGlassParts(null);
|
this.updateGlassParts(null);
|
||||||
|
|
@ -974,13 +967,10 @@ export const useMainStore = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
saveCapabilityQuestionAnswers(capabilityQuestionAnswersArray) {
|
saveCapabilityQuestionAnswers(capabilityQuestionAnswersArray) {
|
||||||
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.capabilityQuestionAnswers,
|
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.capabilityQuestionAnswers, 'result');
|
||||||
'result');
|
const sortedCapabilityQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(capabilityQuestionAnswersArray, 'result');
|
||||||
const sortedCapabilityQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(capabilityQuestionAnswersArray,
|
const haveCapabilityQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedCapabilityQuestionAnswersArray.length
|
||||||
'result');
|
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedCapabilityQuestionAnswersArray[i].result);
|
||||||
const haveCapabilityQuestionAnswersChanged
|
|
||||||
= sortedPreviousResultsArray?.length !== sortedCapabilityQuestionAnswersArray.length
|
|
||||||
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedCapabilityQuestionAnswersArray[i].result);
|
|
||||||
|
|
||||||
if (haveCapabilityQuestionAnswersChanged) {
|
if (haveCapabilityQuestionAnswersChanged) {
|
||||||
this.updateGlassParts(null);
|
this.updateGlassParts(null);
|
||||||
|
|
@ -1064,10 +1054,12 @@ export const useMainStore = defineStore({
|
||||||
endpoint: endpoints.LogPageView.url,
|
endpoint: endpoints.LogPageView.url,
|
||||||
payload,
|
payload,
|
||||||
logApiCall: false
|
logApiCall: false
|
||||||
}).then((response) => response,
|
}).then(
|
||||||
|
(response) => response,
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log(`Analytics Service Error: ${error.data}`);
|
console.log(`Analytics Service Error: ${error.data}`);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
logCustomEvent({ userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId, experimentsForUser }) {
|
logCustomEvent({ userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId, experimentsForUser }) {
|
||||||
if (pageName == null || pageName.length === 0) { pageName = 'none'; }
|
if (pageName == null || pageName.length === 0) { pageName = 'none'; }
|
||||||
|
|
@ -1091,10 +1083,12 @@ export const useMainStore = defineStore({
|
||||||
endpoint: endpoints.LogCustomEvent.url,
|
endpoint: endpoints.LogCustomEvent.url,
|
||||||
payload,
|
payload,
|
||||||
logApiCall: false
|
logApiCall: false
|
||||||
}).then((response) => response,
|
}).then(
|
||||||
|
(response) => response,
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log(`Analytics Service Error: ${error.data}`);
|
console.log(`Analytics Service Error: ${error.data}`);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
initializeSession({ userId, sessionId, userAgent, referrer }) {
|
initializeSession({ userId, sessionId, userAgent, referrer }) {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|
@ -1113,10 +1107,12 @@ export const useMainStore = defineStore({
|
||||||
endpoint: endpoints.InitializeSession.url,
|
endpoint: endpoints.InitializeSession.url,
|
||||||
payload,
|
payload,
|
||||||
logApiCall: false
|
logApiCall: false
|
||||||
}).then((response) => response,
|
}).then(
|
||||||
|
(response) => response,
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log(`Analytics Service Error: ${error.data}`);
|
console.log(`Analytics Service Error: ${error.data}`);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateLastPageVisited(lastPageVisited) {
|
updateLastPageVisited(lastPageVisited) {
|
||||||
|
|
@ -1290,19 +1286,17 @@ export const useMainStore = defineStore({
|
||||||
// Private Functions
|
// Private Functions
|
||||||
|
|
||||||
function getHasRecalibrationPart(state) {
|
function getHasRecalibrationPart(state) {
|
||||||
const hasRequiresRecalibration
|
const hasRequiresRecalibration = getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, 'requiresRecalibration')?.length > 0;
|
||||||
= getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts,
|
const hasRecalibrationType = getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, 'recalibrationType')?.length > 0;
|
||||||
'requiresRecalibration')?.length > 0;
|
|
||||||
const hasRecalibrationType
|
|
||||||
= getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts,
|
|
||||||
'recalibrationType')?.length > 0;
|
|
||||||
|
|
||||||
if (hasRequiresRecalibration) {
|
if (hasRequiresRecalibration) {
|
||||||
if (hasRecalibrationType) {
|
if (hasRecalibrationType) {
|
||||||
// Has both 'requiresRecalibration' and 'recalibrationType' and 'recalibrationType'
|
// Has both 'requiresRecalibration' and 'recalibrationType' and 'recalibrationType'
|
||||||
return (
|
return (
|
||||||
getNonFalseValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts,
|
getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||||
'recalibrationType')[0].toLowerCase() !== 'unknown'
|
state.order.lineItems.glassParts,
|
||||||
|
'recalibrationType'
|
||||||
|
)[0].toLowerCase() !== 'unknown'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Has 'requiresRecalibration' but no 'recalibrationType' at all
|
// Has 'requiresRecalibration' but no 'recalibrationType' at all
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue