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